danielharan / timestamped_boolean

A rails plugin that creates boolean methods on a timestamped field

This URL has Read+Write access

jamesgolick (author)
Mon Jul 07 11:55:58 -0700 2008
Daniel Haran (committer)
Mon Jul 07 14:02:09 -0700 2008
name age message
file MIT-LICENSE Loading commit data...
file README
file init.rb
directory lib/
directory test/
README
TimestampedBoolean
==================

For an AR object called Job with a published_at field, call:

timestamped_boolean :published_at

This will create the methods published and published? which return true if the timestamp is not nil

Object.published will return a chainable has_finder which does what you would expect...

Finally, 
-publish sets the timestamp
-publish! also saves the record
-published = sets a timestamp or nil for true and false, respectively

For a field like created_at, you can specify the timestamp verb:

timestamped_boolean :created_at, :create

which will give you create and create! instead of created and created!

Copyright (c) 2008 Daniel Haran, released under the MIT license