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-cartography to your Gemfile

gem 'attribute-cartographer'

Then run:

$ bundle

USAGE

class Mapper
  include AttributeCartographer

  map :a, :b
  map :c, :d, ->(v) { v.downcase }
end

 = Mapper.new a: 123, c: "Mapper"
.b # => 123
.d # => "Mapper"
.original_attributes # => { a: 123, c: "Mapper" }

REQUIREMENTS

  • Ruby 1.9.x

LICENSE

MIT