Class: ProcessEngine::Parser::Extension::FormField

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element) ⇒ FormField

Returns a new instance of FormField.



4
5
6
# File 'app/models/process_engine/parser/extension/form_field.rb', line 4

def initialize(element)
  @element = element
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



2
3
4
# File 'app/models/process_engine/parser/extension/form_field.rb', line 2

def element
  @element
end

Class Method Details

.factory(extension_element) ⇒ Object



47
48
49
# File 'app/models/process_engine/parser/extension/form_field.rb', line 47

def self.factory(extension_element)
  data = extension_element.xpath("camunda:formData//camunda:formField").map{ |ff| new(ff) }
end

Instance Method Details

#default_valueObject



20
21
22
# File 'app/models/process_engine/parser/extension/form_field.rb', line 20

def default_value
  element["defaultValue"]
end

#idObject



8
9
10
# File 'app/models/process_engine/parser/extension/form_field.rb', line 8

def id
  element["id"]
end

#labelObject



12
13
14
# File 'app/models/process_engine/parser/extension/form_field.rb', line 12

def label
  element["label"]
end

#propertiesObject



24
25
26
27
28
# File 'app/models/process_engine/parser/extension/form_field.rb', line 24

def properties
  element.xpath("camunda:properties//camunda:property").each_with_object({}) do |prop, hash|
    hash[prop["id"]] = prop["value"]
  end
end

#to_hObject



36
37
38
39
40
41
42
43
44
45
# File 'app/models/process_engine/parser/extension/form_field.rb', line 36

def to_h
  {
    id: id,
    label: label,
    type: type,
    default_value: default_value,
    properties: properties,
    validation: validation
  }
end

#typeObject



16
17
18
# File 'app/models/process_engine/parser/extension/form_field.rb', line 16

def type
  element["type"]
end

#validationObject



30
31
32
33
34
# File 'app/models/process_engine/parser/extension/form_field.rb', line 30

def validation
  element.xpath("camunda:validation//camunda:constraint").each_with_object({}) do |constraint, hash|
    hash[constraint["name"]] = constraint["config"]
  end
end