Created
April 6, 2015 20:02
-
-
Save lucasrenan/7c71b5a130d9788cd6d7 to your computer and use it in GitHub Desktop.
This file contains 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 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