Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. require 'memoist'
  2.  
  3. class A
  4. extend Memoist
  5.  
  6. def foo
  7. puts 'A'
  8. end
  9.  
  10. memoize :foo
  11. end
  12.  
  13. class B < A
  14. def foo
  15. puts 'B'
  16. end
  17. end
  18.  
  19. class C < A
  20. def foo
  21. puts 'C'
  22. end
  23.  
  24. memoize :foo
  25. end
  26.  
  27. class D < A
  28. def foo
  29. puts 'D'
  30. end
  31.  
  32. memoize :foo, identifier: :d_foo
  33. end
  34.  
  35. a = A.new
  36. a.foo
  37. a.foo
  38.  
  39. b = B.new
  40. b.foo
  41. b.foo
  42.  
  43. c = C.new
  44. c.foo
  45. c.foo
  46.  
  47. d = D.new
  48. d.foo
  49. d.foo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement