class Dynflow::ExecutionPlan::OutputReference
Attributes
action_id[R]
execution_plan_id[R]
step_id[R]
subkeys[R]
Public Class Methods
dereference(object, persistence)
click to toggle source
dereferences all OutputReferences in Hash-Array structure
# File lib/dynflow/execution_plan/output_reference.rb, line 8 def self.dereference(object, persistence) case object when Hash object.reduce(Utils.indifferent_hash({})) do |h, (key, val)| h.update(key => dereference(val, persistence)) end when Array object.map { |val| dereference(val, persistence) } when self object.dereference(persistence) else object end end
deserialize(value)
click to toggle source
dereferences all hashes representing OutputReferences in Hash-Array structure
# File lib/dynflow/execution_plan/output_reference.rb, line 24 def self.deserialize(value) case value when Hash if value[:class] == self.to_s new_from_hash(value) else value.reduce(Utils.indifferent_hash({})) do |h, (key, val)| h.update(key => deserialize(val)) end end when Array value.map { |val| deserialize(val) } else value end end
new(execution_plan_id, step_id, action_id, subkeys = [])
click to toggle source
# File lib/dynflow/execution_plan/output_reference.rb, line 43 def initialize(execution_plan_id, step_id, action_id, subkeys = []) @execution_plan_id = Type! execution_plan_id, String @step_id = Type! step_id, Integer @action_id = Type! action_id, Integer Type! subkeys, Array @subkeys = subkeys.map { |v| Type!(v, String, Symbol).to_s }.freeze end
new_from_hash(hash)
click to toggle source
# File lib/dynflow/execution_plan/output_reference.rb, line 78 def self.new_from_hash(hash) check_class_matching hash new(hash.fetch(:execution_plan_id), hash.fetch(:step_id), hash.fetch(:action_id), hash.fetch(:subkeys)) end
Public Instance Methods
[](subkey)
click to toggle source
# File lib/dynflow/execution_plan/output_reference.rb, line 51 def [](subkey) self.class.new(execution_plan_id, step_id, action_id, subkeys + [subkey]) end
dereference(persistence)
click to toggle source
# File lib/dynflow/execution_plan/output_reference.rb, line 71 def dereference(persistence) action_data = persistence.adapter.load_action(execution_plan_id, action_id) @subkeys.reduce(action_data[:output]) { |v, k| v.fetch k } end
to_hash()
click to toggle source
# File lib/dynflow/execution_plan/output_reference.rb, line 55 def to_hash recursive_to_hash class: self.class.to_s, execution_plan_id: execution_plan_id, step_id: step_id, action_id: action_id, subkeys: subkeys end
to_s()
click to toggle source
# File lib/dynflow/execution_plan/output_reference.rb, line 63 def to_s "Step(#{step_id}).output".dup.tap do |ret| ret << subkeys.map { |k| "[:#{k}]" }.join('') if subkeys.any? end end
Also aliased as: inspect