Event Attribute plugin

Plugin details

EventAttribute allows you to turn your date/datetime columns in to boolean attributes.

Websitehttp://www.daikini.com/past/2007/6/21/eventattribute_rails_plugin_boolean_datetime/ Repositorysvn://svn.roundhaus.com/daikini/plugins/event_attribute Author Jonathan Younger Tags event, Date, Time LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install svn://svn.roundhaus.com/daikini/plugins/event_attribute
class Referral < ActiveRecord::Base
  event_attribute :applied_at, :attribute => 'pending', :nil_equals => true
  event_attribute :subscribed_on
end

referral = Referral.create(:applied_at => Time.now)
referral.pending?           # => false
referral.subscribed?        # => false

referral.pending = true
referral.applied_at         # => nil
referral.pending?           # => true

referral.subscribed = true
referral.subscribed_at      # => Time.now
referral.subscribed?        # => true


# Dynamic finders are also added so that you can search on these boolean attributes.
Referral.find_all_by_pending(true)  # => [Referral objects]

# or
Referral.find_by_name_and_pending_and_subscribed('John Smith', false, true)  # => Referral object

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 7 months ago