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.



270
271
272
# File 'lib/acts_as_audited.rb', line 270

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



243
244
245
# File 'lib/acts_as_audited.rb', line 243

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

#disable_auditingObject



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

def disable_auditing
  write_inheritable_attribute :auditing_enabled, false
end

#enable_auditingObject



263
264
265
# File 'lib/acts_as_audited.rb', line 263

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


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

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