Created
November 9, 2011 01:23
-
-
Save brianstorti/1350008 to your computer and use it in GitHub Desktop.
extend and include
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 Test | |
def class_method | |
"class method" | |
end | |
end | |
class A | |
extend Test | |
end | |
puts A.class_method | |
#extend is basically a shortcut for including a module to the eigenclass: | |
class B | |
class << self | |
include Test | |
end | |
end | |
puts B.class_method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment