Module: Auditor::Auditable::ClassMethods

Defined in:
lib/auditor/auditable.rb

Instance Method Summary collapse

Instance Method Details

#audit(*args, &blk) ⇒ Object



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

def audit(*args, &blk)
  unless self.included_modules.include?(Auditor::Auditable::InstanceMethods)
    include InstanceMethods
    include Auditor::Status unless self.included_modules.include?(Auditor::Status)
    has_many :audits, :as => :auditable
  end

  config = Auditor::Config.new(*args)
  config.actions.each do |action|
    send "after_#{action}", Auditor::Recorder.new(config.options, &blk)
  end
end

#audit!(*args, &blk) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/auditor/auditable.rb', line 26

def audit!(*args, &blk)
  if args.last.kind_of?(Hash)
    args.last[:fail_on_error] = true
  else
    args << { :fail_on_error => true }
  end

  audit(*args, &blk)
end