Module: EventAttribute
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/event_attribute.rb,
lib/event_attribute/version.rb
Overview
EventAttribute allows you to turn your date/datetime columns in to boolean attributes. Idea for this was taken from jamis.jamisbuck.org/articles/2005/12/14/two-tips-for-working-with-databases-in-rails
class Referral < ActiveRecord::Base
event_attribute :applied_at, :attribute => 'pending', :nil_equals => true
event_attribute :subscribed_on
end
Example:
referral = Referral.create(:applied_at => Time.now, :subscribed_on => nil)
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
See EventAttribute::ClassMethods#event_attribute for configuration options
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
"1.0.1"