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