Skip to content

Instantly share code, notes, and snippets.

@kennethkalmer
Created June 5, 2014 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennethkalmer/fcc470851d9556321ab0 to your computer and use it in GitHub Desktop.
Save kennethkalmer/fcc470851d9556321ab0 to your computer and use it in GitHub Desktop.
Module magic with extend self, and extending others
irb(main):001:0> Bar.bar
=> :barred
irb(main):002:0> Bar.new.bar
=> :barred
irb(main):003:0> Foo.bar
=> :barred
module Foo
extend self
def self.included(base)
base.extend(self)
end
def bar
:barred
end
end
class Bar
include Foo
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment