Sha256: 6908686b34a9fb1bdc70bf1d0a8d3cc454fcefdce1d7be0a9333ab13e3aa5769
Contents?: true
Size: 969 Bytes
Versions: 12
Compression:
Stored size: 969 Bytes
Contents
# encoding: utf-8 module Punchblock module HasHeaders ## # @return [Hash] hash of key-value pairs of headers # def headers_hash headers.inject({}) do |hash, header| hash[header.name.downcase.gsub('-', '_').to_sym] = header.value hash end end ## # @return [Array[Header]] headers # def headers find('//ns:header', :ns => self.class.registered_ns).map do |i| Header.new i end end ## # @param [Hash, Array] headers A hash of key-value header pairs, or an array of Header objects # 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 def inspect_attributes # :nodoc: [:headers_hash] + super end end end
Version data entries
12 entries across 12 versions & 1 rubygems