Class: ProcessEngine::Parser::Extension::TransitionalParameter
- Inherits:
-
Object
- Object
- ProcessEngine::Parser::Extension::TransitionalParameter
- Defined in:
- app/models/process_engine/parser/extension/transitional_parameter.rb
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(element) ⇒ TransitionalParameter
constructor
A new instance of TransitionalParameter.
- #list ⇒ Object
- #map ⇒ Object
- #script ⇒ Object
- #string ⇒ Object
- #to_h ⇒ Object
- #type ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(element) ⇒ TransitionalParameter
Returns a new instance of TransitionalParameter.
4 5 6 7 |
# File 'app/models/process_engine/parser/extension/transitional_parameter.rb', line 4 def initialize(element) @element = element @name = element["name"] end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
2 3 4 |
# File 'app/models/process_engine/parser/extension/transitional_parameter.rb', line 2 def element @element end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'app/models/process_engine/parser/extension/transitional_parameter.rb', line 2 def name @name end |
Class Method Details
.factory(element, direction) ⇒ Object
50 51 52 |
# File 'app/models/process_engine/parser/extension/transitional_parameter.rb', line 50 def self.factory(element, direction) element.xpath("camunda:#{direction}").map { |el| new(el) } end |
Instance Method Details
#list ⇒ Object
9 10 11 12 |
# File 'app/models/process_engine/parser/extension/transitional_parameter.rb', line 9 def list l = element.xpath("camunda:list//camunda:value").map(&:content) l.present? ? l : nil end |
#map ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/models/process_engine/parser/extension/transitional_parameter.rb', line 14 def map h = element.xpath("camunda:map//camunda:entry").each_with_object({}) do |item, hash| hash[item["key"]] = item.content end h.present? ? h : nil end |
#script ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/models/process_engine/parser/extension/transitional_parameter.rb', line 26 def script sct = element.at_xpath("camunda:script") return nil unless sct obj = (Struct.new(:script_format, :script_content)).new obj.script_format = sct["scriptFormat"] obj.script_content = sct.content obj end |
#string ⇒ Object
22 23 24 |
# File 'app/models/process_engine/parser/extension/transitional_parameter.rb', line 22 def string element.elements.count == 0 ? element.content : nil end |
#to_h ⇒ Object
43 44 45 46 47 48 |
# File 'app/models/process_engine/parser/extension/transitional_parameter.rb', line 43 def to_h { type: type, value: value } end |
#type ⇒ Object
35 36 37 |
# File 'app/models/process_engine/parser/extension/transitional_parameter.rb', line 35 def type %w(list string map script).find {|item| send(item).present? } end |
#value ⇒ Object
39 40 41 |
# File 'app/models/process_engine/parser/extension/transitional_parameter.rb', line 39 def value send(type) end |