Class: SpotFlow::Bpmn::Step

Inherits:
Element
  • Object
show all
Defined in:
lib/spot_flow/bpmn/step.rb

Direct Known Subclasses

Activity, Event, Gateway, Process

Instance Attribute Summary collapse

Attributes inherited from Element

#extension_elements, #id, #name

Instance Method Summary collapse

Methods inherited from Element

#inspect

Constructor Details

#initialize(attributes = {}) ⇒ Step

Returns a new instance of Step.



8
9
10
11
12
13
14
# File 'lib/spot_flow/bpmn/step.rb', line 8

def initialize(attributes = {})
  super(attributes.except(:incoming, :outgoing, :default))

  @incoming = Array.wrap(attributes[:incoming]) || []
  @outgoing = Array.wrap(attributes[:outgoing]) || []
  @default_ref = attributes[:default]
end

Instance Attribute Details

#defaultObject

Returns the value of attribute default.



6
7
8
# File 'lib/spot_flow/bpmn/step.rb', line 6

def default
  @default
end

#default_refObject

Returns the value of attribute default_ref.



6
7
8
# File 'lib/spot_flow/bpmn/step.rb', line 6

def default_ref
  @default_ref
end

#incomingObject

Returns the value of attribute incoming.



6
7
8
# File 'lib/spot_flow/bpmn/step.rb', line 6

def incoming
  @incoming
end

#outgoingObject

Returns the value of attribute outgoing.



6
7
8
# File 'lib/spot_flow/bpmn/step.rb', line 6

def outgoing
  @outgoing
end

Instance Method Details

#converging?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/spot_flow/bpmn/step.rb', line 20

def converging?
  incoming.length > 1
end

#diverging?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/spot_flow/bpmn/step.rb', line 16

def diverging?
  outgoing.length > 1
end

#input_mappingsObject



39
40
41
# File 'lib/spot_flow/bpmn/step.rb', line 39

def input_mappings
  extension_elements&.io_mapping&.inputs || []
end

#leave(execution) ⇒ Object



24
25
26
27
# File 'lib/spot_flow/bpmn/step.rb', line 24

def leave(execution)
  execution.end(false)
  execution.take_all(outgoing_flows(execution))
end

#outgoing_flows(execution) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/spot_flow/bpmn/step.rb', line 29

def outgoing_flows(execution)
  flows = []
  outgoing.each do |flow|
    result = flow.evaluate(execution) unless default&.id == flow.id
    flows.push flow if result
  end
  flows = [default] if flows.empty? && default
  return flows
end

#output_mappingsObject



43
44
45
# File 'lib/spot_flow/bpmn/step.rb', line 43

def output_mappings
  extension_elements&.io_mapping&.outputs || []
end