Skip to content

Instantly share code, notes, and snippets.

@lucasrenan
Created April 6, 2015 20:02
Show Gist options
  • Save lucasrenan/7c71b5a130d9788cd6d7 to your computer and use it in GitHub Desktop.
Save lucasrenan/7c71b5a130d9788cd6d7 to your computer and use it in GitHub Desktop.
module Foo
def self.included(base)
base.extend(ClassMethods)
# alternative
def base.class_name
"class method name"
end
end
def instance_name
"instance method name"
end
module ClassMethods
def find
"findddddd"
end
end
end
class Person
include Foo
end
p = Person.new
p.instance_name # => "instance method name"
Person.class_name # => "class method name"
Person.find # => findddddd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment