Ninja
the library behind the scenes
Installation
Add this line to your application's Gemfile:
gem 'ninja-collection'
And then execute:
$ bundle install
Usage
Ninja::Hash
require 'ninja/hash'
h = Ninja::Hash.new(hoge: 1, foo: 2)
h.hoge # => 1
h.foo # => 2
h.piyo # => nil
h.bar = 100
h.bar # => 100
h = {hoge: 1, foo: 2}.to_ninja_hash
h.hoge # => 1
h.foo # => 2
h_ninja = {hoge: 1, foo: 2}.ninja
h_ninja.hoge # => 1
h_ninja.foo # => 2
h = {hoge: 1, foo: { bar: 2 }}.ninja
h.foo.bar # => 2
# default value
h.get(:piyo) { 1 + 2 } # => 3
h.get(:piyo) # => nil
Contributing
- 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