Created
August 13, 2012 14:41
-
-
Save pi3r/3341323 to your computer and use it in GitHub Desktop.
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
Basically i had : | |
class Base | |
def self.match_attributes(hash, attributes = self::ATTRIBUTES_MAPPING) | |
#do work on attributes | |
end | |
end | |
class SpecificMapper < Base | |
ATTRIBUTES_MAPPING = { ... } | |
end | |
Then i could do : | |
Base.match_attributes(hash, { ... }) | |
or | |
SpecificMapper.match_attributes(hash) | |
Then i read http://matt.aimonetti.net/posts/2012/07/30/ruby-class-module-mixins/ and i wanted to refactor that because i'm not using any instance methods. | |
module Foo | |
def self.hello | |
puts "Yo" | |
end | |
end | |
module Bar | |
include Foo | |
end | |
Foo.hello #=> Yo | |
Bar.hello #=> NotMethodError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment