Sha256: 2f8b3be79257fb8ed1fdf26e437fe80cc4f504c0974e821fc5b9a34a1737b5ad
Contents?: true
Size: 1.43 KB
Versions: 3
Compression:
Stored size: 1.43 KB
Contents
# Yahm Yahm is a hash to hash translator for ruby. ## Installation Add this line to your application's Gemfile: gem 'yahm' And then execute: $ bundle Or install it yourself as: $ gem install yahm ## Dependencies None ## Usage ### Most basic example ```ruby require "yahm" class Record extend Yahm::HashMapper define_mapper :from_other_record do map "/record/id", to: "/id" end end Record.new.from_other_record({ ... }) => { :id => "..." } ``` ### More advanced example ```ruby require "yahm" class Record extend Yahm::HashMapper attr_accessor :translated_hash define_mapper :from_other_record, call_setter: :translated_hash= do map "/record/id", to: "/id" map "/record/count", to: "/count", processed_by: :to_i map "/record/subject[0]", to: "/subjects/most_important_subject" end end Record.new.from_other_record({ ... }) => { :id => "...", :count => ..., :subjects => { :most_important_subject => "..."} } Record.translated_hash => { :id => "...", :count => ..., :subjects => { :most_important_subject => "..."} } ``` ## Related work * hash_mapper (https://github.com/ismasan/hash_mapper) ## Contributing 1. Fork it ( http://github.com/<my-github-username>/yahm/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yahm-0.0.5 | README.md |
yahm-0.0.4 | README.md |
yahm-0.0.3 | README.md |