Created
July 15, 2010 10:26
-
-
Save solnic/476775 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
| #!/usr/bin/env ruby | |
| module A | |
| def self.included(base) | |
| base.extend ClassMethods | |
| end | |
| def a_instance_method | |
| puts 'a instance method' | |
| end | |
| module ClassMethods | |
| def a_class_method | |
| puts 'a class method' | |
| end | |
| end | |
| end | |
| module B | |
| def self.included(base) | |
| base.send :include, A | |
| base.extend ClassMethods | |
| end | |
| def b_instance_method | |
| puts 'b instance method' | |
| end | |
| module ClassMethods | |
| def b_class_method | |
| puts 'b class method' | |
| end | |
| end | |
| end | |
| class Bar | |
| include B | |
| end | |
| class Foo < Bar; end | |
| Bar.a_class_method | |
| Bar.new.a_instance_method | |
| Bar.b_class_method | |
| Bar.new.b_instance_method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment