Class: Stateoscope::AdapterRegistry

Inherits:
Struct
  • Object
show all
Defined in:
lib/stateoscope/adapter_registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAdapterRegistry

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

#adaptersObject

Returns the value of attribute adapters

Returns:

  • (Object)

    the current value of 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