Created
November 21, 2011 21:43
-
-
Save jkamenik/1384045 to your computer and use it in GitHub Desktop.
Ruby module instance and class 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
module Foo | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def bar | |
end | |
end | |
def baz | |
end | |
end | |
class Test | |
include Foo | |
end | |
Test.bar # class method | |
Test.new.bar # No method error | |
Test.baz # No method error | |
Test.new.baz # Instance method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment