Skip to content

Instantly share code, notes, and snippets.

@jayrobin

jayrobin/including_a_module.rb Secret

Last active Oct 11, 2016
Embed
What would you like to do?
# A representation of the module in question
module FormatHelper
def phone_number
# return formatted contact number
end
end
class MyClass
include FormatHelper
def self.my_method
phone_number
end
end
MyClass.my_method # fails with “phone_number undefined”
MyClass.phone_number # error
MyClass.new.phone_number # works, because it includes the methods on the instance of MyClass and not the class MyClass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.