Class: SpotFlow::Bpmn::Definitions

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/spot_flow/bpmn/definitions.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Definitions

Returns a new instance of Definitions.



25
26
27
28
29
30
31
32
# File 'lib/spot_flow/bpmn/definitions.rb', line 25

def initialize(attributes={})
  super(attributes.except(:message, :signal, :error, :process))

  @messages = Array.wrap(attributes[:message]).map { |atts| Message.new(atts) }
  @signals = Array.wrap(attributes[:signal]).map { |atts| Signal.new(atts) }
  @errors = Array.wrap(attributes[:error]).map { |atts| Error.new(atts) }
  @processes = Array.wrap(attributes[:process]).map { |atts| Process.new(atts) }
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



9
10
11
# File 'lib/spot_flow/bpmn/definitions.rb', line 9

def errors
  @errors
end

#execution_platformObject

Returns the value of attribute execution_platform.



8
9
10
# File 'lib/spot_flow/bpmn/definitions.rb', line 8

def execution_platform
  @execution_platform
end

#execution_platform_versionObject

Returns the value of attribute execution_platform_version.



8
9
10
# File 'lib/spot_flow/bpmn/definitions.rb', line 8

def execution_platform_version
  @execution_platform_version
end

#exporterObject

Returns the value of attribute exporter.



8
9
10
# File 'lib/spot_flow/bpmn/definitions.rb', line 8

def exporter
  @exporter
end

#exporter_versionObject

Returns the value of attribute exporter_version.



8
9
10
# File 'lib/spot_flow/bpmn/definitions.rb', line 8

def exporter_version
  @exporter_version
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/spot_flow/bpmn/definitions.rb', line 8

def id
  @id
end

#messagesObject (readonly)

Returns the value of attribute messages.



9
10
11
# File 'lib/spot_flow/bpmn/definitions.rb', line 9

def messages
  @messages
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/spot_flow/bpmn/definitions.rb', line 8

def name
  @name
end

#processesObject (readonly)

Returns the value of attribute processes.



9
10
11
# File 'lib/spot_flow/bpmn/definitions.rb', line 9

def processes
  @processes
end

#signalsObject (readonly)

Returns the value of attribute signals.



9
10
11
# File 'lib/spot_flow/bpmn/definitions.rb', line 9

def signals
  @signals
end

#target_namespaceObject

Returns the value of attribute target_namespace.



8
9
10
# File 'lib/spot_flow/bpmn/definitions.rb', line 8

def target_namespace
  @target_namespace
end

Class Method Details

.from_xml(xml) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/spot_flow/bpmn/definitions.rb', line 11

def self.from_xml(xml)
  XmlHasher.configure do |config|
    config.snakecase = true
    config.ignore_namespaces = true
    config.string_keys = false
  end
  hash = XmlHasher.parse(xml)
  Definitions.new(hash[:definitions].except(:bpmn_diagram)).tap do |definitions|
    definitions.processes.each do |process|
      process.wire_references(definitions)
    end
  end
end

Instance Method Details

#error_by_id(id) ⇒ Object



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

def error_by_id(id)
  errors.find { |error| error.id == id }
end

#inspectObject



50
51
52
# File 'lib/spot_flow/bpmn/definitions.rb', line 50

def inspect
  "#<Bpmn::Definitions @id=#{id.inspect} @name=#{name.inspect} @messages=#{messages.inspect} @signals=#{signals.inspect} @errors=#{errors.inspect} @processes=#{processes.inspect}>"
end

#message_by_id(id) ⇒ Object



34
35
36
# File 'lib/spot_flow/bpmn/definitions.rb', line 34

def message_by_id(id)
  messages.find { |message| message.id == id }
end

#process_by_id(id) ⇒ Object



46
47
48
# File 'lib/spot_flow/bpmn/definitions.rb', line 46

def process_by_id(id)
  processes.find { |process| process.id == id }
end

#signal_by_id(id) ⇒ Object



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

def signal_by_id(id)
  signals.find { |signal| signal.id == id }
end