Module: Audited::Auditor::AuditedClassMethods

Defined in:
lib/audited/auditor.rb

Overview

InstanceMethods

Instance Method Summary collapse

Instance Method Details

#audit_as(user, &block) ⇒ Object

All audit operations during the block are recorded as being made by user. This is not model specific, the method is a convenience wrapper around

See Also:

  • Audit#as_user.


444
445
446
# File 'lib/audited/auditor.rb', line 444

def audit_as( user, &block )
  Audited.audit_class.as_user( user, &block )
end

#audited_columnsObject

Returns an array of columns that are audited. See non_audited_columns



416
417
418
# File 'lib/audited/auditor.rb', line 416

def audited_columns
  self.columns.select { |c| !non_audited_columns.include?(c.name) }
end

#disable_auditingObject



432
433
434
# File 'lib/audited/auditor.rb', line 432

def disable_auditing
  self.auditing_enabled = false
end

#enable_auditingObject



436
437
438
# File 'lib/audited/auditor.rb', line 436

def enable_auditing
  self.auditing_enabled = true
end

#without_auditing(&block) ⇒ Object

Executes the block with auditing disabled.

Foo.without_auditing do
  @foo.save
end


426
427
428
429
430
# File 'lib/audited/auditor.rb', line 426

def without_auditing(&block)
  auditing_was_enabled = auditing_enabled
  disable_auditing
  block.call.tap { enable_auditing if auditing_was_enabled }
end