Last active
December 30, 2015 13:29
-
-
Save e0da/7835834 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
module Helpers | |
def help | |
puts 'helpful!' | |
end | |
end | |
class Foo | |
def get_help | |
self.extend Helpers | |
help # will work because this instance now has Helpers.help | |
end | |
def fail | |
help # will raise exception even after #get_help runs | |
end | |
end | |
Foo.new.get_help # prints 'helpful!' | |
Foo.new.fail # raises exception even after that last instance got extended with Helpers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment