Sha256: fe86eb8b4ed111359c56c1606cd034dfb63d4786c4e866d388a60ce7083aefc0

Contents?: true

Size: 700 Bytes

Versions: 52

Compression:

Stored size: 700 Bytes

Contents

require 'volt'

module Volt
  # Wrapper around a Hash for easy http header creation / manipulation with
  # indifferent access.
  # header[:content_type] == header['Content-Type'] ==
  # header['content-type'] == header ['Content_Type']
  class HttpResponseHeader < Hash
    def []=(key, value)
      super(key.to_s.headerize, value)
    end

    def [](key)
      super(key.to_s.headerize)
    end

    def delete(key)
      super(key.to_s.headerize)
    end

    def merge(other)
      dup.merge!(other)
    end

    def merge!(other)
      new_hash = {}
      other.each_with_object(new_hash) do |(key, value), hash|
        self[key.to_s.headerize] = value
      end
      self
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
volt-0.9.1.pre1 lib/volt/server/rack/http_response_header.rb
volt-0.9.0 lib/volt/server/rack/http_response_header.rb
volt-0.9.0.pre7 lib/volt/server/rack/http_response_header.rb
volt-0.9.0.pre6 lib/volt/server/rack/http_response_header.rb
volt-0.9.0.pre5 lib/volt/server/rack/http_response_header.rb
volt-0.9.0.pre4 lib/volt/server/rack/http_response_header.rb
volt-0.9.0.pre3 lib/volt/server/rack/http_response_header.rb
volt-0.9.0.pre2 lib/volt/server/rack/http_response_header.rb
volt-0.9.0.pre1 lib/volt/server/rack/http_response_header.rb
volt-0.8.27.beta9 lib/volt/server/rack/http_response_header.rb
volt-0.8.27.beta8 lib/volt/server/rack/http_response_header.rb
volt-0.8.27.beta7 lib/volt/server/rack/http_response_header.rb