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.5.pre2 lib/volt/server/rack/http_response_header.rb
volt-0.9.5.pre1 lib/volt/server/rack/http_response_header.rb
volt-0.9.4 lib/volt/server/rack/http_response_header.rb
volt-0.9.4.pre5 lib/volt/server/rack/http_response_header.rb
volt-0.9.4.pre3 lib/volt/server/rack/http_response_header.rb
volt-0.9.4.pre2 lib/volt/server/rack/http_response_header.rb
volt-0.9.4.pre1 lib/volt/server/rack/http_response_header.rb
volt-0.9.3 lib/volt/server/rack/http_response_header.rb
volt-0.9.3.pre6 lib/volt/server/rack/http_response_header.rb
volt-0.9.3.pre5 lib/volt/server/rack/http_response_header.rb
volt-0.9.3.pre4 lib/volt/server/rack/http_response_header.rb
volt-0.9.3.pre3 lib/volt/server/rack/http_response_header.rb
volt-0.9.3.pre2 lib/volt/server/rack/http_response_header.rb
volt-0.9.3.pre1 lib/volt/server/rack/http_response_header.rb
volt-0.9.2 lib/volt/server/rack/http_response_header.rb
volt-0.9.1 lib/volt/server/rack/http_response_header.rb
volt-0.9.1.pre5 lib/volt/server/rack/http_response_header.rb
volt-0.9.1.pre4 lib/volt/server/rack/http_response_header.rb
volt-0.9.1.pre3 lib/volt/server/rack/http_response_header.rb
volt-0.9.1.pre2 lib/volt/server/rack/http_response_header.rb