Class: Volt::HttpResponseHeader

Inherits:
Hash show all
Defined in:
lib/volt/server/rack/http_response_header.rb

Overview

Wrapper around a Hash for easy http header creation / manipulation with indifferent access. header == header == header == header [‘Content_Type’]

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



13
14
15
# File 'lib/volt/server/rack/http_response_header.rb', line 13

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

#[]=(key, value) ⇒ Object



9
10
11
# File 'lib/volt/server/rack/http_response_header.rb', line 9

def []=(key, value)
  super(key.to_s.headerize, value)
end

#delete(key) ⇒ Object



17
18
19
# File 'lib/volt/server/rack/http_response_header.rb', line 17

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

#merge(other) ⇒ Object



21
22
23
# File 'lib/volt/server/rack/http_response_header.rb', line 21

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

#merge!(other) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/volt/server/rack/http_response_header.rb', line 25

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