Last active
December 20, 2016 02:09
-
-
Save thiagoa/0d0f1f23663b4f57f48a8c78047c0f39 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
UselessAble.module_eval do | |
# This is written in the module's instance methods collection | |
def guess_what? | |
puts "I'm useless!" | |
end | |
end | |
def UselessAble.who? | |
puts 'I am an abstract behavior, but I do exist somehow!' | |
end | |
class AssHole | |
include UselessAble | |
end | |
AssHole.new.guess_what? #=> outputs "I’m useless!" | |
AssHole.new.who? #=> Errors out! AssHole instances don't respond to this method. | |
UselessAble.who? #=> outputs "I am an abstract behavior, but I do exist somehow!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment