Predicates are truth accessors for your Ruby classes and models. Yep, that's about it.
Extend your class or model with Predicates and define the predicate by supplying an attribute:
require 'predicates' class User extend Predicates attr_accessor :confirmed predicate :confirmed? end user = User.new user.confirmed = 1 user.confirmed? #=> true
Predicates will also create an attribute writer for you using
attr_writer if the attribute you supplied has not been predefined.
class User extend Predicates predicate :confirmed? end user = User.new user.confirmed = 1 user.confirmed? #=> true
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install predicates
git checkout -b my-new-feature)
git commit -am 'Added some feature')
git push origin my-new-feature)