Module: Punchblock::HasHeaders
- Included in:
- Command::Accept, Command::Answer, Command::Dial, Command::Hangup, Command::Redirect, Command::Reject, Event::Answered, Event::End, Event::Offer, Event::Ringing
- Defined in:
- lib/punchblock/has_headers.rb
Instance Method Summary collapse
-
#headers ⇒ Array[Header]
Headers.
- #headers=(headers) ⇒ Object
-
#headers_hash ⇒ Hash
Hash of key-value pairs of headers.
-
#inspect_attributes ⇒ Object
:nodoc:.
Instance Method Details
#headers ⇒ Array[Header]
Returns headers.
16 17 18 19 20 |
# File 'lib/punchblock/has_headers.rb', line 16 def headers find('//ns:header', :ns => self.class.registered_ns).map do |i| Header.new i end end |
#headers=(headers) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/punchblock/has_headers.rb', line 25 def headers=(headers) find('//ns:header', :ns => self.class.registered_ns).each &:remove if headers.is_a? Hash headers.each_pair { |k,v| self << Header.new(k, v) } elsif headers.is_a? Array [headers].flatten.each { |i| self << Header.new(i) } end end |
#headers_hash ⇒ Hash
Returns hash of key-value pairs of headers.
6 7 8 9 10 11 |
# File 'lib/punchblock/has_headers.rb', line 6 def headers_hash headers.inject({}) do |hash, header| hash[header.name] = header.value hash end end |
#inspect_attributes ⇒ Object
:nodoc:
34 35 36 |
# File 'lib/punchblock/has_headers.rb', line 34 def inspect_attributes # :nodoc: [:headers_hash] + super end |