Class: BPMN::Definitions
- Inherits:
-
Object
- Object
- BPMN::Definitions
- Includes:
- ActiveModel::Model
- Defined in:
- lib/bpmn/definitions.rb
Constant Summary collapse
- MODEL_ATTRIBUTES =
%i[ id name target_namespace exporter exporter_version execution_platform execution_platform_version ].freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#escalations ⇒ Object
readonly
Returns the value of attribute escalations.
-
#execution_platform ⇒ Object
Returns the value of attribute execution_platform.
-
#execution_platform_version ⇒ Object
Returns the value of attribute execution_platform_version.
-
#exporter ⇒ Object
Returns the value of attribute exporter.
-
#exporter_version ⇒ Object
Returns the value of attribute exporter_version.
-
#id ⇒ Object
Returns the value of attribute id.
-
#item_definitions ⇒ Object
readonly
Returns the value of attribute item_definitions.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#name ⇒ Object
Returns the value of attribute name.
-
#processes ⇒ Object
readonly
Returns the value of attribute processes.
-
#signals ⇒ Object
readonly
Returns the value of attribute signals.
-
#target_namespace ⇒ Object
Returns the value of attribute target_namespace.
Class Method Summary collapse
Instance Method Summary collapse
- #error_by_id(id) ⇒ Object
- #escalation_by_id(id) ⇒ Object
-
#initialize(attributes = {}) ⇒ Definitions
constructor
A new instance of Definitions.
- #inspect ⇒ Object
- #item_definition_by_id(id) ⇒ Object
- #message_by_id(id) ⇒ Object
- #process_by_id(id) ⇒ Object
- #signal_by_id(id) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Definitions
Returns a new instance of Definitions.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bpmn/definitions.rb', line 28 def initialize(attributes={}) super(attributes.slice(*MODEL_ATTRIBUTES)) @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) } @escalations = Array.wrap(attributes[:escalation]).map { |atts| Escalation.new(atts) } @item_definitions = Array.wrap(attributes[:item_definition]).map { |atts| ItemDefinition.new(atts) } @processes = Array.wrap(attributes[:process]).map { |atts| Process.new(atts) } end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
12 13 14 |
# File 'lib/bpmn/definitions.rb', line 12 def errors @errors end |
#escalations ⇒ Object (readonly)
Returns the value of attribute escalations.
12 13 14 |
# File 'lib/bpmn/definitions.rb', line 12 def escalations @escalations end |
#execution_platform ⇒ Object
Returns the value of attribute execution_platform.
11 12 13 |
# File 'lib/bpmn/definitions.rb', line 11 def execution_platform @execution_platform end |
#execution_platform_version ⇒ Object
Returns the value of attribute execution_platform_version.
11 12 13 |
# File 'lib/bpmn/definitions.rb', line 11 def execution_platform_version @execution_platform_version end |
#exporter ⇒ Object
Returns the value of attribute exporter.
11 12 13 |
# File 'lib/bpmn/definitions.rb', line 11 def exporter @exporter end |
#exporter_version ⇒ Object
Returns the value of attribute exporter_version.
11 12 13 |
# File 'lib/bpmn/definitions.rb', line 11 def exporter_version @exporter_version end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/bpmn/definitions.rb', line 11 def id @id end |
#item_definitions ⇒ Object (readonly)
Returns the value of attribute item_definitions.
12 13 14 |
# File 'lib/bpmn/definitions.rb', line 12 def item_definitions @item_definitions end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
12 13 14 |
# File 'lib/bpmn/definitions.rb', line 12 def @messages end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/bpmn/definitions.rb', line 11 def name @name end |
#processes ⇒ Object (readonly)
Returns the value of attribute processes.
12 13 14 |
# File 'lib/bpmn/definitions.rb', line 12 def processes @processes end |
#signals ⇒ Object (readonly)
Returns the value of attribute signals.
12 13 14 |
# File 'lib/bpmn/definitions.rb', line 12 def signals @signals end |
#target_namespace ⇒ Object
Returns the value of attribute target_namespace.
11 12 13 |
# File 'lib/bpmn/definitions.rb', line 11 def target_namespace @target_namespace end |
Class Method Details
.from_xml(xml) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bpmn/definitions.rb', line 14 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
47 48 49 |
# File 'lib/bpmn/definitions.rb', line 47 def error_by_id(id) errors.find { |error| error.id == id } end |
#escalation_by_id(id) ⇒ Object
51 52 53 |
# File 'lib/bpmn/definitions.rb', line 51 def escalation_by_id(id) escalations.find { |escalation| escalation.id == id } end |
#inspect ⇒ Object
63 64 65 |
# File 'lib/bpmn/definitions.rb', line 63 def inspect "#<BPMN::Definitions @id=#{id.inspect} @name=#{name.inspect} @messages=#{.inspect} @signals=#{signals.inspect} @errors=#{errors.inspect} @escalations=#{escalations.inspect} @item_definitions=#{item_definitions.inspect} @processes=#{processes.inspect}>" end |
#item_definition_by_id(id) ⇒ Object
59 60 61 |
# File 'lib/bpmn/definitions.rb', line 59 def item_definition_by_id(id) item_definitions.find { |item| item.id == id } end |
#message_by_id(id) ⇒ Object
39 40 41 |
# File 'lib/bpmn/definitions.rb', line 39 def (id) .find { || .id == id } end |
#process_by_id(id) ⇒ Object
55 56 57 |
# File 'lib/bpmn/definitions.rb', line 55 def process_by_id(id) processes.find { |process| process.id == id } end |
#signal_by_id(id) ⇒ Object
43 44 45 |
# File 'lib/bpmn/definitions.rb', line 43 def signal_by_id(id) signals.find { |signal| signal.id == id } end |