Created
April 21, 2010 23:50
-
-
Save hosh/374602 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Animal | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def say | |
"animal" | |
end | |
end | |
end | |
class Slug | |
include Animal | |
end | |
class Cat | |
def self.say | |
"meow" | |
end | |
end | |
class Dog | |
class << self | |
def say | |
"woof" | |
end | |
end | |
end | |
Slug.say | |
Cat.say | |
Dog.say | |
Cat.send(:include, Animal) | |
Cat.say | |
Dog.send(:include, Animal) | |
Dog.say |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment