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
510 511 512 |
# File 'lib/audited/auditor.rb', line 510 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
456 457 458 |
# File 'lib/audited/auditor.rb', line 456 def audited_columns @audited_columns ||= column_names - non_audited_columns end |
#auditing_enabled ⇒ Object
514 515 516 |
# File 'lib/audited/auditor.rb', line 514 def auditing_enabled class_auditing_enabled && Audited.auditing_enabled end |
#auditing_enabled=(val) ⇒ Object
518 519 520 |
# File 'lib/audited/auditor.rb', line 518 def auditing_enabled=(val) Audited.store["#{table_name}_auditing_enabled"] = val end |
#default_ignored_attributes ⇒ Object
522 523 524 |
# File 'lib/audited/auditor.rb', line 522 def default_ignored_attributes [primary_key, inheritance_column] | Audited.ignored_attributes end |
#disable_auditing ⇒ Object
498 499 500 |
# File 'lib/audited/auditor.rb', line 498 def disable_auditing self.auditing_enabled = false end |
#enable_auditing ⇒ Object
502 503 504 |
# File 'lib/audited/auditor.rb', line 502 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
461 462 463 |
# File 'lib/audited/auditor.rb', line 461 def non_audited_columns @non_audited_columns ||= calculate_non_audited_columns end |
#non_audited_columns=(columns) ⇒ Object
465 466 467 468 |
# File 'lib/audited/auditor.rb', line 465 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
490 491 492 493 494 495 496 |
# File 'lib/audited/auditor.rb', line 490 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
476 477 478 479 480 481 482 |
# File 'lib/audited/auditor.rb', line 476 def without_auditing auditing_was_enabled = class_auditing_enabled disable_auditing yield ensure enable_auditing if auditing_was_enabled end |