Module: ActsAsAudited::Auditor::SingletonMethods

Defined in:
lib/acts_as_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.


268
269
270
# File 'lib/acts_as_audited/auditor.rb', line 268

def audit_as( user, &block )
  Audit.as_user( user, &block )
end

#audited_columnsObject

Returns an array of columns that are audited. See non_audited_columns



238
239
240
# File 'lib/acts_as_audited/auditor.rb', line 238

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

#disable_auditingObject

Disable auditing.



255
256
257
# File 'lib/acts_as_audited/auditor.rb', line 255

def disable_auditing
  self.auditing_enabled = false
end

#enable_auditingObject

Enable auditing.



260
261
262
# File 'lib/acts_as_audited/auditor.rb', line 260

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


248
249
250
251
252
# File 'lib/acts_as_audited/auditor.rb', line 248

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