Module: Audited::Auditor::AuditedClassMethods
- Defined in:
- lib/audited/auditor.rb
Instance Method Summary collapse
-
#audit_as(user, &block) ⇒ Object
All audit operations during the block are recorded as being made by
user
. -
#audited_columns ⇒ Object
Returns an array of columns that are audited.
- #auditing_enabled ⇒ Object
- #auditing_enabled=(val) ⇒ Object
- #default_ignored_attributes ⇒ Object
- #disable_auditing ⇒ Object
- #enable_auditing ⇒ Object
-
#non_audited_columns ⇒ Object
We have to calculate this here since column_names may not be available when ‘audited` is called.
- #non_audited_columns=(columns) ⇒ Object
-
#with_auditing ⇒ Object
Executes the block with auditing enabled.
-
#without_auditing ⇒ Object
Executes the block with auditing disabled.
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
482 483 484 |
# File 'lib/audited/auditor.rb', line 482 def audit_as(user, &block) Audited.audit_class.as_user(user, &block) end |
#audited_columns ⇒ Object
Returns an array of columns that are audited. See non_audited_columns
428 429 430 |
# File 'lib/audited/auditor.rb', line 428 def audited_columns @audited_columns ||= column_names - non_audited_columns end |
#auditing_enabled ⇒ Object
486 487 488 |
# File 'lib/audited/auditor.rb', line 486 def auditing_enabled class_auditing_enabled && Audited.auditing_enabled end |
#auditing_enabled=(val) ⇒ Object
490 491 492 |
# File 'lib/audited/auditor.rb', line 490 def auditing_enabled=(val) Audited.store["#{table_name}_auditing_enabled"] = val end |
#default_ignored_attributes ⇒ Object
494 495 496 |
# File 'lib/audited/auditor.rb', line 494 def default_ignored_attributes [primary_key, inheritance_column] | Audited.ignored_attributes end |
#disable_auditing ⇒ Object
470 471 472 |
# File 'lib/audited/auditor.rb', line 470 def disable_auditing self.auditing_enabled = false end |
#enable_auditing ⇒ Object
474 475 476 |
# File 'lib/audited/auditor.rb', line 474 def enable_auditing self.auditing_enabled = true end |
#non_audited_columns ⇒ Object
We have to calculate this here since column_names may not be available when ‘audited` is called
433 434 435 |
# File 'lib/audited/auditor.rb', line 433 def non_audited_columns @non_audited_columns ||= calculate_non_audited_columns end |
#non_audited_columns=(columns) ⇒ Object
437 438 439 440 |
# File 'lib/audited/auditor.rb', line 437 def non_audited_columns=(columns) @audited_columns = nil # reset cached audited columns on assignment @non_audited_columns = columns.map(&:to_s) end |
#with_auditing ⇒ Object
Executes the block with auditing enabled.
Foo.with_auditing do
@foo.save
end
462 463 464 465 466 467 468 |
# File 'lib/audited/auditor.rb', line 462 def with_auditing auditing_was_enabled = class_auditing_enabled enable_auditing yield ensure disable_auditing unless auditing_was_enabled end |
#without_auditing ⇒ Object
Executes the block with auditing disabled.
Foo.without_auditing do
@foo.save
end
448 449 450 451 452 453 454 |
# File 'lib/audited/auditor.rb', line 448 def without_auditing auditing_was_enabled = class_auditing_enabled disable_auditing yield ensure enable_auditing if auditing_was_enabled end |