Skip to content

Instantly share code, notes, and snippets.

@thiagoa
Last active December 20, 2016 02:09
Show Gist options
  • Save thiagoa/0d0f1f23663b4f57f48a8c78047c0f39 to your computer and use it in GitHub Desktop.
Save thiagoa/0d0f1f23663b4f57f48a8c78047c0f39 to your computer and use it in GitHub Desktop.
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