Attribute Cartographer
DESCRIPTION
Attribute Cartographer allows you to map an attributes hash into similarly or differently named methods, using an optional block to map the values as well.
INSTALL
Add attribute-cartographer to your Gemfile
gem 'attribute-cartographer'
Then run:
$ bundle
USAGE
class Mapper
include AttributeCartographer
map :a
map :b, ->(v) { v.downcase }
map :c, :d
map :e, :f, ->(v) { v.downcase }
map :g, :h, ->(v) { v.downcase }, ->(v) { v.upcase }
map [:i, :j, :k]
map [:l, :m, :n], ->(v) { v.upcase }
end
mapper = Mapper.new attributes
mapper.original_attributes # => {:a=>123, :c=>"Mapper", :e=>"Eee!", :f=>"F.", :g=>"Gee!"}
REQUIREMENTS
-
Ruby 1.9.x
LICENSE
MIT