Guest User

Untitled

a guest
May 24th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. module A
  2. def hello
  3. puts "hola"
  4. end
  5. end
  6.  
  7. # Instead of module_function, let's include A in its own metaclass so we
  8. # can both include the methods in other classes and call the methods a class methods of the module
  9. module A
  10. class << self
  11. include ::A
  12. end
  13. end
  14.  
  15. class B
  16. include A
  17. end
  18.  
  19. A.hello # => "hola"
  20. B.new.hello # => "hola"
Add Comment
Please, Sign In to add comment