Class: ServiceFlowRegistry

Inherits:
Object
  • Object
show all
Defined in:
app/lib/service_flow_registry.rb

Overview

A registry of ServiceFlow.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.service_flowsObject (readonly)

Returns the value of attribute service_flows.



19
20
21
# File 'app/lib/service_flow_registry.rb', line 19

def service_flows
  @service_flows
end

Class Method Details

.flows(service) ⇒ Hash

Return all service flows for the given Service.

Parameters:

  • service (Service)

    the service to load flows for

Returns:

  • (Hash)

    flows for the service



26
27
28
# File 'app/lib/service_flow_registry.rb', line 26

def self.flows(service)
  @service_flows[service.name.to_sym]
end

.load!(service, flow) ⇒ ServiceFlow

Load a ServiceFlow given the Service and flow.

Parameters:

  • service (Service)

    the service to load a flow for

  • flow (Symbol)

    the flow to load

Returns:

Raises:



35
36
37
38
39
40
41
# File 'app/lib/service_flow_registry.rb', line 35

def self.load!(service, flow)
  service_flow = @service_flows.dig(service.name.to_sym, flow)

  raise Exceptions::MissingServiceFlowError, "Service #{service.name} missing #{flow} flow" if service_flow.nil?

  service_flow.new(service)
end