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

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



309
310
311
# File 'lib/acts_as_audited_rails3/base.rb', line 309

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



282
283
284
# File 'lib/acts_as_audited_rails3/base.rb', line 282

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

#disable_auditingObject



298
299
300
# File 'lib/acts_as_audited_rails3/base.rb', line 298

def disable_auditing
  write_inheritable_attribute :auditing_enabled, false
end

#enable_auditingObject



302
303
304
# File 'lib/acts_as_audited_rails3/base.rb', line 302

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


292
293
294
295
296
# File 'lib/acts_as_audited_rails3/base.rb', line 292

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