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
592 593 594 |
# File 'lib/audited/auditor.rb', line 592 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
538 539 540 |
# File 'lib/audited/auditor.rb', line 538 def audited_columns @audited_columns ||= column_names - non_audited_columns end |
#auditing_enabled ⇒ Object
596 597 598 |
# File 'lib/audited/auditor.rb', line 596 def auditing_enabled class_auditing_enabled && Audited.auditing_enabled end |
#auditing_enabled=(val) ⇒ Object
600 601 602 |
# File 'lib/audited/auditor.rb', line 600 def auditing_enabled=(val) Audited.store["#{table_name}_auditing_enabled"] = val end |
#default_ignored_attributes ⇒ Object
604 605 606 |
# File 'lib/audited/auditor.rb', line 604 def default_ignored_attributes [primary_key, inheritance_column] | Audited.ignored_attributes end |
#disable_auditing ⇒ Object
580 581 582 |
# File 'lib/audited/auditor.rb', line 580 def disable_auditing self.auditing_enabled = false end |
#enable_auditing ⇒ Object
584 585 586 |
# File 'lib/audited/auditor.rb', line 584 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
543 544 545 |
# File 'lib/audited/auditor.rb', line 543 def non_audited_columns @non_audited_columns ||= calculate_non_audited_columns end |
#non_audited_columns=(columns) ⇒ Object
547 548 549 550 |
# File 'lib/audited/auditor.rb', line 547 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
572 573 574 575 576 577 578 |
# File 'lib/audited/auditor.rb', line 572 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
558 559 560 561 562 563 564 |
# File 'lib/audited/auditor.rb', line 558 def without_auditing auditing_was_enabled = class_auditing_enabled disable_auditing yield ensure enable_auditing if auditing_was_enabled end |