Simple programmatic building of hashes.
Add this line to your application's Gemfile:
gem 'hash_generator'
And then execute:
bundle
Or install it yourself as:
gem install hash_generator
Use #store
to store primitive values:
require 'hash_generator'
generator = HashGenerator.new
generator.store(:hello, 'world!')
generator.to_h # => {:hello=>"world!"}
Or use #new_object
and #store_scope
to nest hashes:
require 'hash_generator'
generator = HashGenerator.new
generator.new_object
generator.store(:hello, 'world!')
generator.store_scope(:object)
generator.to_h # => {:object=>{:hello=>"world!"}}
Or use #new_array
and #push_scope
to push objects into an array:
require 'hash_generator'
generator = HashGenerator.new
generator.new_array
generator.new_object
generator.store(:hello, 'world!')
generator.push_scope
generator.store_scope(:array)
generator.to_h # => {:array=>[{:hello=>"world!"}]}
- Fork it (https://github.com/IvyApp/hash\_generator/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request