Module: Auditable::Auditor::ClassMethods

Defined in:
lib/auditable/auditor.rb

Instance Method Summary collapse

Instance Method Details

#audit(opts = {}) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/auditable/auditor.rb', line 11

def audit(opts = {})
  options = HashWithIndifferentAccess.new({ :attributes => [], :methods => [] }).merge(opts)
  add_auditable_actions(options[:methods])
  add_auditable_attributes(options[:attributes])
  has_many :audit_records, :as => :auditable

  include Auditor::InstanceMethods
end

#audited_attributesObject



20
21
22
23
24
25
26
# File 'lib/auditable/auditor.rb', line 20

def audited_attributes
  if self.base_class == self
    Array(@audited_attributes)
  else
    self.base_class.audited_attributes if @audited_attributes.nil?
  end
end