Nonexistent

Automated NullObject pattern in ruby

Installation

Add this line to your application's Gemfile:

gem 'nonexistent'

And then execute:

$ bundle

Or install it yourself as:

$ gem install nonexistent

Usage

Include Nonexistent at the top of which ever class you want to use the null object pattern in.

Override defaults by passing in the attribute name and the default type as a hash.

For example:

class User
  include Nonexistent
  default_null_object_attributes { first_name: 'No', last_name: 'Name' }

end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lollar/nonexistent.