Skip to content

Instantly share code, notes, and snippets.

@olegantonyan
Last active October 26, 2015 03:22
Show Gist options
  • Save olegantonyan/73872d290f04e519e3c5 to your computer and use it in GitHub Desktop.
Save olegantonyan/73872d290f04e519e3c5 to your computer and use it in GitHub Desktop.
Mixin class methods
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