Class: WorkflowTemplate::Definer::HasActions::Inside

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reference, block) ⇒ Inside

Returns a new instance of Inside.



11
12
13
14
15
# File 'lib/workflow_template/definer/has_actions/inside.rb', line 11

def initialize(reference, block)
  @reference = reference
  @block = block
  freeze
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



9
10
11
# File 'lib/workflow_template/definer/has_actions/inside.rb', line 9

def block
  @block
end

#referenceObject (readonly)

Returns the value of attribute reference.



9
10
11
# File 'lib/workflow_template/definer/has_actions/inside.rb', line 9

def reference
  @reference
end

Instance Method Details

#apply_onto(actions, action) ⇒ Object

Raises:



17
18
19
20
21
22
23
# File 'lib/workflow_template/definer/has_actions/inside.rb', line 17

def apply_onto(actions, action)
  raise Error, 'Action expected to be nil' unless action.nil?

  before, action, after = Position.slice_actions(actions, reference)
  clone = action.duplicate(&block)
  [*before, clone, *after]
end