Module: Auditor::Status
- Included in:
- Recorder, SpecHelpers
- Defined in:
- lib/auditor/status.rb
Instance Method Summary collapse
- #audit_as(user) ⇒ Object
- #auditing_disabled? ⇒ Boolean
- #auditing_enabled? ⇒ Boolean
- #disable_auditing ⇒ Object
- #enable_auditing ⇒ Object
- #with_auditing ⇒ Object
- #without_auditing ⇒ Object
Instance Method Details
#audit_as(user) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/auditor/status.rb', line 48 def audit_as(user) previous_user = Auditor::User.current_user begin Auditor::User.current_user = user result = yield if block_given? ensure Auditor::User.current_user = previous_user end result end |
#auditing_disabled? ⇒ Boolean
6 7 8 |
# File 'lib/auditor/status.rb', line 6 def auditing_disabled? Thread.current[:auditor_disabled] == true end |
#auditing_enabled? ⇒ Boolean
10 11 12 |
# File 'lib/auditor/status.rb', line 10 def auditing_enabled? Thread.current[:auditor_disabled] == false end |
#disable_auditing ⇒ Object
14 15 16 |
# File 'lib/auditor/status.rb', line 14 def disable_auditing Thread.current[:auditor_disabled] = true end |
#enable_auditing ⇒ Object
18 19 20 |
# File 'lib/auditor/status.rb', line 18 def enable_auditing Thread.current[:auditor_disabled] = false end |
#with_auditing ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/auditor/status.rb', line 35 def with_auditing previously_disabled = auditing_disabled? begin enable_auditing result = yield if block_given? ensure disable_auditing if previously_disabled end result end |
#without_auditing ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/auditor/status.rb', line 22 def without_auditing previously_disabled = auditing_disabled? begin disable_auditing result = yield if block_given? ensure enable_auditing unless previously_disabled end result end |