Module: Igniter::Contracts::Execution::BaselineRuntime
- Defined in:
- lib/igniter/contracts/execution/baseline_runtime.rb
Class Method Summary collapse
- .handle_compute(operation:, state:) ⇒ Object
- .handle_effect(operation:, state:, profile:) ⇒ Object
- .handle_input(operation:, inputs:) ⇒ Object
- .handle_output(operation:, state:) ⇒ Object
- .resolve_dependency_values(operation, state:) ⇒ Object
- .unsupported(kind) ⇒ Object
Class Method Details
.handle_compute(operation:, state:) ⇒ Object
13 14 15 16 17 |
# File 'lib/igniter/contracts/execution/baseline_runtime.rb', line 13 def handle_compute(operation:, state:, **) callable = operation.attributes[:callable] kwargs = resolve_dependency_values(operation, state: state) callable.call(**kwargs) end |
.handle_effect(operation:, state:, profile:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/igniter/contracts/execution/baseline_runtime.rb', line 19 def handle_effect(operation:, state:, profile:, **) callable = operation.attributes[:callable] effect_name = operation.attributes.fetch(:using).to_sym dependency_values = resolve_dependency_values(operation, state: state) payload = callable.call(**dependency_values) invocation = EffectInvocation.new( payload: payload, context: { node_name: operation.name, effect_name: effect_name, dependencies: dependency_values }, profile: profile ) profile.effect(effect_name).call(invocation: invocation) end |
.handle_input(operation:, inputs:) ⇒ Object
9 10 11 |
# File 'lib/igniter/contracts/execution/baseline_runtime.rb', line 9 def handle_input(operation:, inputs:, **) inputs.fetch(operation.name) end |
.handle_output(operation:, state:) ⇒ Object
37 38 39 |
# File 'lib/igniter/contracts/execution/baseline_runtime.rb', line 37 def handle_output(operation:, state:, **) state.fetch(operation.name) end |
.resolve_dependency_values(operation, state:) ⇒ Object
47 48 49 50 51 |
# File 'lib/igniter/contracts/execution/baseline_runtime.rb', line 47 def resolve_dependency_values(operation, state:) Array(operation.attributes[:depends_on]).each_with_object({}) do |dependency, memo| memo[dependency.to_sym] = state.fetch(dependency.to_sym) end end |
.unsupported(kind) ⇒ Object
41 42 43 44 45 |
# File 'lib/igniter/contracts/execution/baseline_runtime.rb', line 41 def unsupported(kind) lambda do |**| raise NotImplementedError, "#{kind} runtime handler is not implemented in the baseline runtime yet" end end |