Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
module MyModule
def self.included(base)
base.extend(ClassMethods)
end
def hellofrominstance
puts "hello from #{self}"
end
# Conventionally named ClassMethods
module ClassMethods
def hellofromclass
puts "Hello from #{self}"
end
end
end
# including MyModule will call the hook (#included) which
# extends the class methods
class Blah
include MyModule
end
pry(main)> Blah.hellofromclass
#=> "Hello from Blah"
pry(main)> Blah.new.hellofrominstance
#=> "hello from #"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.