Class: ProcessEngine::Parser::Extension::TransitionalParameter

Inherits:
Object
  • Object
show all
Defined in:
app/models/process_engine/parser/extension/transitional_parameter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#elementObject (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

#nameObject (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

#listObject



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

#mapObject



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

#scriptObject



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

#stringObject



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_hObject



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

#typeObject



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

#valueObject



39
40
41
# File 'app/models/process_engine/parser/extension/transitional_parameter.rb', line 39

def value
  send(type)
end