4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/sekken/example_message.rb', line 4
def self.build(parts)
memo = {}
parts.each do |element|
name = element.name.to_sym
case
when element.simple_type?
base_type_local = element.base_type.split(':').last
base_type_local = [base_type_local] unless element.singular?
memo[name] = base_type_local
when element.complex_type?
value = build(element.children)
unless element.attributes.empty?
value.merge! collect_attributes(element)
end
value = [value] unless element.singular?
memo[name] = value
end
end
memo
end
|