Class: BPMN::Definitions

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Definitions



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

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.



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

def errors
  @errors
end

#execution_platformObject

Returns the value of attribute execution_platform.



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

def execution_platform
  @execution_platform
end

#execution_platform_versionObject

Returns the value of attribute execution_platform_version.



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

def execution_platform_version
  @execution_platform_version
end

#exporterObject

Returns the value of attribute exporter.



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

def exporter
  @exporter
end

#exporter_versionObject

Returns the value of attribute exporter_version.



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

def exporter_version
  @exporter_version
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#messagesObject (readonly)

Returns the value of attribute messages.



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

def messages
  @messages
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#processesObject (readonly)

Returns the value of attribute processes.



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

def processes
  @processes
end

#signalsObject (readonly)

Returns the value of attribute signals.



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

def signals
  @signals
end

#target_namespaceObject

Returns the value of attribute target_namespace.



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

def target_namespace
  @target_namespace
end

Class Method Details

.from_xml(xml) ⇒ Object



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

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



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

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

#inspectObject



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

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



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

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

#process_by_id(id) ⇒ Object



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

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

#signal_by_id(id) ⇒ Object



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

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