Sha256: b890216298fc2338a0918e7fae1ed0ebf3975f3d0cf9bbaffba059c688e512bd

Contents?: true

Size: 769 Bytes

Versions: 18

Compression:

Stored size: 769 Bytes

Contents

# encoding: utf-8

module Punchblock
  module HasHeaders
    def self.included(klass)
      klass.attribute :headers, Hash, default: {}
    end

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

    def inherit(xml_node)
      xml_node.xpath('//ns:header', ns: self.class.registered_ns).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

    def rayo_children(root)
      super
      headers.each do |name, value|
        Array(value).each do |v|
          root.header name: name, value: v
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
punchblock-2.5.3 lib/punchblock/has_headers.rb
punchblock-2.5.2 lib/punchblock/has_headers.rb
punchblock-2.5.1 lib/punchblock/has_headers.rb
punchblock-2.5.0 lib/punchblock/has_headers.rb
punchblock-2.4.2 lib/punchblock/has_headers.rb
punchblock-2.4.0 lib/punchblock/has_headers.rb
punchblock-2.3.1 lib/punchblock/has_headers.rb
punchblock-2.3.0 lib/punchblock/has_headers.rb
punchblock-2.2.2 lib/punchblock/has_headers.rb
punchblock-2.2.1 lib/punchblock/has_headers.rb
punchblock-2.2.0 lib/punchblock/has_headers.rb
punchblock-2.1.1 lib/punchblock/has_headers.rb
punchblock-2.1.0 lib/punchblock/has_headers.rb
punchblock-2.0.2 lib/punchblock/has_headers.rb
punchblock-2.0.1 lib/punchblock/has_headers.rb
punchblock-2.0.0 lib/punchblock/has_headers.rb
punchblock-2.0.0.beta2 lib/punchblock/has_headers.rb
punchblock-2.0.0.beta1 lib/punchblock/has_headers.rb