Guest User

Untitled

a guest
Jun 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. class Some
  2. def initialize(name)
  3. @name = name
  4. end
  5. def hello
  6. p "hello, #{@name}"
  7. end
  8. end
  9.  
  10. def some_factory
  11. Some.new('bot')
  12. end
  13.  
  14. module AnotherModule
  15. def goodbye
  16. p "goodbye, #{@name}"
  17. end
  18. end
  19.  
  20. class Another < Some
  21. include AnotherModule
  22. end
  23.  
  24. def another_factory(type)
  25. if type
  26. Another.new('master')
  27. else
  28. some = some_factory
  29. some.extend(AnotherModule)
  30. end
  31. end
  32.  
  33. another_factory(false).hello
  34. another_factory(true).hello
Add Comment
Please, Sign In to add comment