Module: Audited::Auditor::AuditedClassMethods
- Defined in:
- lib/audited/auditor.rb
Overview
InstanceMethods
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
- #disable_auditing ⇒ Object
- #enable_auditing ⇒ Object
- #non_audited_columns ⇒ Object
-
#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
296 297 298 |
# File 'lib/audited/auditor.rb', line 296 def audit_as(user, &block) Audit.as_user(user, &block) end |
#audited_columns ⇒ Object
Returns an array of columns that are audited. See non_audited_columns
253 254 255 |
# File 'lib/audited/auditor.rb', line 253 def audited_columns columns.select {|c| !non_audited_columns.include?(c.name) } end |
#auditing_enabled ⇒ Object
300 301 302 |
# File 'lib/audited/auditor.rb', line 300 def auditing_enabled Audited.store.fetch("#{table_name}_auditing_enabled", true) end |
#auditing_enabled=(val) ⇒ Object
304 305 306 |
# File 'lib/audited/auditor.rb', line 304 def auditing_enabled=(val) Audited.store["#{table_name}_auditing_enabled"] = val end |
#disable_auditing ⇒ Object
284 285 286 |
# File 'lib/audited/auditor.rb', line 284 def disable_auditing self.auditing_enabled = false end |
#enable_auditing ⇒ Object
288 289 290 |
# File 'lib/audited/auditor.rb', line 288 def enable_auditing self.auditing_enabled = true end |
#non_audited_columns ⇒ Object
257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/audited/auditor.rb', line 257 def non_audited_columns @non_audited_columns ||= begin = if [:only] except = column_names - Array.wrap([:only]).flatten.map(&:to_s) else except = default_ignored_attributes + Audited.ignored_attributes except |= Array([:except]).collect(&:to_s) if [:except] end except end end |
#without_auditing ⇒ Object
Executes the block with auditing disabled.
Foo.without_auditing do
@foo.save
end
276 277 278 279 280 281 282 |
# File 'lib/audited/auditor.rb', line 276 def without_auditing auditing_was_enabled = auditing_enabled disable_auditing yield ensure enable_auditing if auditing_was_enabled end |