Created
December 9, 2012 14:30
-
-
Save yangchenyun/4245259 to your computer and use it in GitHub Desktop.
examples to show module callback methods
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
# GistID: 4245259 | |
module TestModule | |
# invoked when the module itself is extended by class | |
def self.extended(base) | |
puts "#{base} extended with #{self}" | |
end | |
# invoked when the mixined module or class is included in another module | |
# see below for more information | |
def append_features(base) | |
puts "#{base} is appended with new features" | |
end | |
end | |
module OneModule | |
extend TestModule | |
# OneModule now has the append_features method | |
# extended from TestModule | |
end | |
module AnotherModule | |
include OneModule | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment