Module: CollectiveIdea::Acts::Audited::SingletonMethods

Defined in:
lib/acts_as_audited.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 #Audit.as_user.



337
338
339
# File 'lib/acts_as_audited.rb', line 337

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



310
311
312
# File 'lib/acts_as_audited.rb', line 310

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

#disable_auditingObject



326
327
328
# File 'lib/acts_as_audited.rb', line 326

def disable_auditing
  write_inheritable_attribute :auditing_enabled, false
end

#enable_auditingObject



330
331
332
# File 'lib/acts_as_audited.rb', line 330

def enable_auditing
  write_inheritable_attribute :auditing_enabled, true
end

#without_auditing(&block) ⇒ Object

Executes the block with auditing disabled.

Foo.without_auditing do
  @foo.save
end


320
321
322
323
324
# File 'lib/acts_as_audited.rb', line 320

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