Module: Punchblock::HasHeaders
- Included in:
- Command::Accept, Command::Answer, Command::Dial, Command::Hangup, Command::Redirect, Command::Reject, Component::Input, Component::Output, Event::Answered, Event::End, Event::Offer, Event::Ringing
- Defined in:
- lib/punchblock/has_headers.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
5 6 7 |
# File 'lib/punchblock/has_headers.rb', line 5 def self.included(klass) klass.attribute :headers, Hash, default: {} end |
Instance Method Details
#headers=(other) ⇒ Object
9 10 11 |
# File 'lib/punchblock/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/punchblock/has_headers.rb', line 13 def inherit(xml_node) xml_node.xpath('//ns:header', ns: 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/punchblock/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_NAMESPACES[:core] end end end |