Class: Crabfarm::Engines::SyncStateManager
- Inherits:
-
Object
- Object
- Crabfarm::Engines::SyncStateManager
- Defined in:
- lib/crabfarm/engines/sync_state_manager.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#initialize(_context) ⇒ SyncStateManager
constructor
A new instance of SyncStateManager.
- #navigate(_name, _params = {}) ⇒ Object
- #reload ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(_context) ⇒ SyncStateManager
Returns a new instance of SyncStateManager.
10 11 12 13 |
# File 'lib/crabfarm/engines/sync_state_manager.rb', line 10 def initialize(_context) @context = _context @lock = Mutex.new end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
8 9 10 |
# File 'lib/crabfarm/engines/sync_state_manager.rb', line 8 def context @context end |
Instance Method Details
#navigate(_name, _params = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/crabfarm/engines/sync_state_manager.rb', line 28 def navigate(_name, _params={}) @lock.synchronize { output = { name: _name, params: _params } output[:elapsed] = Benchmark.measure do output[:doc] = TransitionService.transition(@context, _name, _params).document end OpenStruct.new output } end |
#reload ⇒ Object
15 16 17 18 19 20 |
# File 'lib/crabfarm/engines/sync_state_manager.rb', line 15 def reload @lock.synchronize { ActiveSupport::Dependencies.clear @context.reset } end |
#reset ⇒ Object
22 23 24 25 26 |
# File 'lib/crabfarm/engines/sync_state_manager.rb', line 22 def reset @lock.synchronize { @context.reset } end |