Created
January 14, 2011 08:53
-
-
Save shouichi/779376 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
#!/usr/bin/env ruby | |
module Teacher | |
def self.included(model) | |
model.instance_eval do | |
extend ClassMethods | |
include InstanceMethods | |
end | |
end | |
module ClassMethods | |
def a_class_method | |
"A class method" | |
end | |
end | |
module InstanceMethods | |
def a_instance_method | |
"An instance method" | |
end | |
end | |
end | |
class Person | |
include Teacher | |
end | |
p Person.a_class_method | |
p Person.new.a_instance_method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment