Class: Stateoscope::AdapterRegistry
- Inherits:
-
Struct
- Object
- Struct
- Stateoscope::AdapterRegistry
- Defined in:
- lib/stateoscope/adapter_registry.rb
Instance Attribute Summary collapse
-
#adapters ⇒ Object
Returns the value of attribute adapters.
Instance Method Summary collapse
- #find(klass, state_machine_name) ⇒ Object
- #find!(klass, state_machine_name) ⇒ Object
-
#initialize ⇒ AdapterRegistry
constructor
A new instance of AdapterRegistry.
- #register(adapter) ⇒ Object
Constructor Details
#initialize ⇒ AdapterRegistry
Returns a new instance of AdapterRegistry.
3 4 5 |
# File 'lib/stateoscope/adapter_registry.rb', line 3 def initialize self.adapters = [] end |
Instance Attribute Details
#adapters ⇒ Object
Returns the value of attribute adapters
2 3 4 |
# File 'lib/stateoscope/adapter_registry.rb', line 2 def adapters @adapters end |
Instance Method Details
#find(klass, state_machine_name) ⇒ Object
11 12 13 14 15 |
# File 'lib/stateoscope/adapter_registry.rb', line 11 def find(klass, state_machine_name) adapters.find do |adapter| adapter.handle?(klass, state_machine_name) end end |
#find!(klass, state_machine_name) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/stateoscope/adapter_registry.rb', line 17 def find!(klass, state_machine_name) adapter = find(klass, state_machine_name) if adapter adapter else fail MissingAdapterError, 'unsupported state machine implementation' end end |
#register(adapter) ⇒ Object
7 8 9 |
# File 'lib/stateoscope/adapter_registry.rb', line 7 def register(adapter) adapters.unshift adapter end |