Last active
October 26, 2015 03:22
-
-
Save olegantonyan/73872d290f04e519e3c5 to your computer and use it in GitHub Desktop.
Mixin class methods
This file contains 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.send :extend, ClassMethods | |
end | |
module ClassMethods # the name doesn't matter as long as it match with line 3 | |
def bar | |
puts 'hello' | |
end | |
end | |
end | |
class Test | |
include Foo | |
end | |
Test.bar #=> hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment