Skip to content

Instantly share code, notes, and snippets.

@jkamenik
Created November 21, 2011 21:43
Show Gist options
  • Save jkamenik/1384045 to your computer and use it in GitHub Desktop.
Save jkamenik/1384045 to your computer and use it in GitHub Desktop.
Ruby module instance and class methods
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