makandra/assignable_values — pull request #8 by bradherman (2014-08-21 19:16:26+00:00)
Title: Add a status option

This adds an option "status" which makes the field "statusable". This defines query methods on the class and checker methods on instances.

For instance, in the following class

class Song
assignable_values_for :genre, status: true do
%w(pop rock techno)
end
end

the class and instances of it will behave like so:

song = Song.new(genre: 'pop')
# song responds to .pop?, .rock?, and .techno? now
# song.{value}? checks song.{property} == {value}
# Song responds to .pop, .rock, .techno
# Song.{value} queries Song.where(property => value)
song.pop?
=> true
song.techno?
=> false
Song.pop
=> AR relation with song