Skip to content

Instantly share code, notes, and snippets.

@pi3r
Created August 13, 2012 14:41
Show Gist options
  • Save pi3r/3341323 to your computer and use it in GitHub Desktop.
Save pi3r/3341323 to your computer and use it in GitHub Desktop.
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