Class: WorkflowTemplate::Definer::HasActions::Actions::Prepared

Inherits:
Object
  • Object
show all
Defined in:
lib/workflow_template/definer/has_actions/actions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(simple:, wrapper:) ⇒ Prepared

Returns a new instance of Prepared.



54
55
56
57
58
# File 'lib/workflow_template/definer/has_actions/actions.rb', line 54

def initialize(simple:, wrapper:)
  @simple = simple.freeze
  @wrapper = wrapper.freeze
  freeze
end

Instance Attribute Details

#simpleObject (readonly)

Returns the value of attribute simple.



52
53
54
# File 'lib/workflow_template/definer/has_actions/actions.rb', line 52

def simple
  @simple
end

#wrapperObject (readonly)

Returns the value of attribute wrapper.



52
53
54
# File 'lib/workflow_template/definer/has_actions/actions.rb', line 52

def wrapper
  @wrapper
end

Instance Method Details

#inspectObject



81
82
83
84
85
# File 'lib/workflow_template/definer/has_actions/actions.rb', line 81

def inspect
  simple = simple().map(&:name).join(', ')
  wrapper = wrapper().map(&:name).join(', ')
  "#<#{self.class.name} simple=[#{simple}] wrapper=[#{wrapper}]>"
end

#map(&block) ⇒ Object



67
68
69
70
71
# File 'lib/workflow_template/definer/has_actions/actions.rb', line 67

def map(&block)
  simple_actions = simple.map(&block)
  wrapper_actions = wrapper.map(&block)
  self.class.new simple: simple_actions, wrapper: wrapper_actions
end

#merge(unprepared) ⇒ Object



60
61
62
63
64
65
# File 'lib/workflow_template/definer/has_actions/actions.rb', line 60

def merge(unprepared)
  simple = unprepared.send(:prepare_simple, existing: self.simple)
  wrapper = unprepared.send(:prepare_wrapper, existing: self.wrapper)

  Prepared.new(simple: simple, wrapper: wrapper)
end

#next_wrapper_actionObject



73
74
75
76
77
78
79
# File 'lib/workflow_template/definer/has_actions/actions.rb', line 73

def next_wrapper_action
  return [nil, self] if wrapper.empty?

  action, *rest = wrapper
  container = self.class.new(simple: simple, wrapper: rest)
  [action, container]
end