Class: BPMN::Step

Inherits:
Element show all
Defined in:
lib/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.



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

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.



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

def default
  @default
end

#default_refObject

Returns the value of attribute default_ref.



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

def default_ref
  @default_ref
end

#incomingObject

Returns the value of attribute incoming.



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

def incoming
  @incoming
end

#outgoingObject

Returns the value of attribute outgoing.



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

def outgoing
  @outgoing
end

Instance Method Details

#converging?Boolean

Returns:

  • (Boolean)


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

def converging?
  incoming.length > 1
end

#diverging?Boolean

Returns:

  • (Boolean)


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

def diverging?
  outgoing.length > 1
end

#input_mappingsObject



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

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

#leave(execution) ⇒ Object



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

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

#outgoing_flows(execution) ⇒ Object



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

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



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

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