Last active
January 10, 2018 01:47
-
-
Save gbpereira/f170926da324357b6999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# módulo | |
module SomeModule | |
# pode ser chamado de qualquer lugar | |
def SomeModule.handle | |
puts 'some method' | |
end | |
# chamado pelas classes que incluem o módulo | |
def handle | |
puts 'other method' | |
end | |
end | |
puts SomeModule.handle | |
#=> some method | |
class SomeClass | |
include SomeModule | |
end | |
c = SomeClass.new | |
puts c.handle | |
#=> other method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment