Module: Adhearsion::HasHeaders

Instance Method Summary collapse

Instance Method Details

#headers=(other) ⇒ Object


9
10
11
# File 'lib/adhearsion/has_headers.rb', line 9

def headers=(other)
  super(other || {})
end

#inherit(xml_node) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/adhearsion/has_headers.rb', line 13

def inherit(xml_node)
  xml_node.xpath('//ns:header', ns: Rayo::RAYO_NAMESPACES[:core]).to_a.each do |header|
    if headers.has_key?(header[:name])
      headers[header[:name]] = [headers[header[:name]]]
      headers[header[:name]] << header[:value]
    else
      headers[header[:name]] = header[:value]
    end
  end
  super
end

#rayo_children(root) ⇒ Object


25
26
27
28
29
30
31
32
# File 'lib/adhearsion/has_headers.rb', line 25

def rayo_children(root)
  super
  headers.each do |name, value|
    Array(value).each do |v|
      root.header name: name, value: v, xmlns: Rayo::RAYO_NAMESPACES[:core]
    end
  end
end