The hash_to_object gem converts a hash into a Class Object. For example:
h = { :title => 'Hello world!' }.to_obj
p h.title
# => "Hello world!"
Add this line to your application's Gemfile:
gem 'hash_to_obj'
And then execute:
$ bundle
Or install it yourself as:
$ gem install hash_to_obj
Using hash_to_object is very simple. Just call the to_obj
method on any valid hash.
h = { :title => 'Hello world!' }.to_obj
p h.title
# => "Hello world!"
- 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