Class: WorkflowTemplate::Definer::HasActions::Actions::Prepared
- Inherits:
-
Object
- Object
- WorkflowTemplate::Definer::HasActions::Actions::Prepared
- Defined in:
- lib/workflow_template/definer/has_actions/actions.rb
Instance Attribute Summary collapse
-
#simple ⇒ Object
readonly
Returns the value of attribute simple.
-
#wrapper ⇒ Object
readonly
Returns the value of attribute wrapper.
Instance Method Summary collapse
-
#initialize(simple:, wrapper:) ⇒ Prepared
constructor
A new instance of Prepared.
- #inspect ⇒ Object
- #map(&block) ⇒ Object
- #merge(unprepared) ⇒ Object
- #next_wrapper_action ⇒ Object
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
#simple ⇒ Object (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 |
#wrapper ⇒ Object (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
#inspect ⇒ Object
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_action ⇒ Object
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 |