Created
September 14, 2010 15:17
-
-
Save foca/579194 to your computer and use it in GitHub Desktop.
Adding class methods from a module, that are added to the class hierarchy (so you can use super, unlike with Module#extend)
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 find(*) | |
"Foo#find" | |
end | |
end | |
class Blah | |
class << self | |
include Foo | |
end | |
def self.find(*) | |
"Blah.find -- #{super}" | |
end | |
end | |
Blah.find #=> "Blah.find -- Foo#find" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment