Skip to content

Instantly share code, notes, and snippets.

@e0da
Last active December 30, 2015 13:29
Show Gist options
  • Save e0da/7835834 to your computer and use it in GitHub Desktop.
Save e0da/7835834 to your computer and use it in GitHub Desktop.
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