Encodes and Decodes key-value hashes.
Add this line to your application's Gemfile:
gem 'flat_keys'
And then execute:
$ bundle
Or install it yourself as:
$ gem install flat_keys
require 'flat_keys'
{'name'=>{'fname'=>'John', 'lname'=>'Doe'}}.flat_keys
#=> {'name.fname'=>'John', 'name.lname'=>'Doe'}
{'name.fname'=>'John', 'name.lname'=>'Doe'}.unflat_keys
#=> {'name'=>{'fname'=>'John', 'lname'=>'Doe'}}
Both flat_keys
and unflat_keys
can be used with custom separators.
{'name'=>{'fname'=>'John', 'lname'=>'Doe'}}.flat_keys('$')
#=> {'name$fname'=>'John', 'name$lname'=>'Doe'}
rake
- Fork it
- 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 new Pull Request