Module: CIA::Auditable::ClassMethods

Defined in:
lib/cia/auditable.rb

Instance Method Summary collapse

Instance Method Details

#audit_attribute(*attributes) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cia/auditable.rb', line 12

def audit_attribute(*attributes)
  options = (attributes.last.is_a?(Hash) ? attributes.pop : {})

  self.audited_attributes = Set.new unless audited_attributes
  self.audited_attributes += attributes.map(&:to_s)

  self.audited_attribute_options ||= {}
  self.audited_attribute_options.merge!(options)

  has_many :cia_events, :class_name => "CIA::Event", :as => :source
  has_many :cia_attribute_changes, :class_name => "CIA::AttributeChange", :as => :source
end