Module: Mongoid::AuditLog

Extended by:
ActiveSupport::Concern
Defined in:
lib/mongoid/audit_log.rb,
lib/mongoid/audit_log/entry.rb,
lib/mongoid/audit_log/config.rb,
lib/mongoid/audit_log/changes.rb,
lib/mongoid/audit_log/restore.rb,
lib/mongoid/audit_log/version.rb

Defined Under Namespace

Classes: Changes, Entry, Restore

Constant Summary collapse

VERSION =
"0.6.1"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.current_modifierObject



71
72
73
# File 'lib/mongoid/audit_log.rb', line 71

def self.current_modifier
  Thread.current[:mongoid_audit_log_modifier]
end

.current_modifier=(modifier) ⇒ Object



75
76
77
# File 'lib/mongoid/audit_log.rb', line 75

def self.current_modifier=(modifier)
  Thread.current[:mongoid_audit_log_modifier] = modifier
end

.disableObject



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/mongoid/audit_log.rb', line 54

def self.disable
  already_recording = recording?
  Thread.current[:mongoid_audit_log_recording] = false

  if block_given?
    begin
      yield
    ensure
      Thread.current[:mongoid_audit_log_recording] = already_recording
    end
  end
end

.enableObject



50
51
52
# File 'lib/mongoid/audit_log.rb', line 50

def self.enable
  Thread.current[:mongoid_audit_log_recording] = true
end

.record(modifier = nil) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/mongoid/audit_log.rb', line 40

def self.record(modifier = nil)
  already_recording = recording?
  enable unless already_recording
  self.current_modifier = modifier
  yield
ensure
  disable unless already_recording
  self.current_modifier = nil
end

.recording?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/mongoid/audit_log.rb', line 67

def self.recording?
  !!Thread.current[:mongoid_audit_log_recording]
end

Instance Method Details

#record_audit_log?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/mongoid/audit_log.rb', line 79

def record_audit_log?
  AuditLog.recording? && self.class.audit_log_enabled?
end