An extended version of Hashie::Trash (for hashie v2+)
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.simplecov
.travis.yml
Gemfile
Guardfile
LICENSE
README.md
Rakefile
hashie-lazy_trash.gemspec

README.md

Hashie::LazyTrash Build Status

An extended Hashie::Trash with the following 2 additional features:

  1. When trying to set a value that is not defined as a property, the LazyTrash just sllently ignores this value (as opposed to Hashie::Trash, which raises an Exception)

  2. You can define properties that are to be fetched lazily (on first access), i.e.

    property :user_id property :user, :lazy => lambda { User.find(user_id) }

    As you can see in this example, the Proc is executed in the context of the Hashie::LazyTrash instance

Usage

This gem relies on the yet-unreleased version 2 of the hashie gem. Therefore, you must get that dependency using bundler from github manually for now:

# Gemfile
gem 'hashie', :github => 'intridea/hashie'
gem 'hashie-lazy_trash'

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request