Module: Smith::Agent::Registry::ExecutionBindingCapture

Included in:
Smith::Agent::Registry
Defined in:
lib/smith/agent/registry/execution_binding_capture.rb

Instance Method Summary collapse

Instance Method Details

#capture_bindings!(requests) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/smith/agent/registry/execution_binding_capture.rb', line 7

def capture_bindings!(requests)
  registry_monitor.synchronize do
    requests.each_with_object({}) do |request, bindings|
      key = normalize_key(request.fetch(:name))
      binding = binding_for(key)
      klass = binding&.fetch(:agent_class, nil)
      unless klass
        raise Smith::WorkflowError,
              "unresolved #{request.fetch(:role)} :#{key}" \
              "#{fetch_suffix(request.fetch(:workflow_class), request.fetch(:transition_name))}"
      end

      bindings[key] = klass
    end.freeze
  end
end