Class: Excon::Headers

Inherits:
Hash
  • Object
show all
Defined in:
lib/excon/headers.rb

Constant Summary collapse

SENTINEL =
{}

Instance Method Summary collapse

Constructor Details

#initializeHeaders

Returns a new instance of Headers.



21
22
23
# File 'lib/excon/headers.rb', line 21

def initialize
  @downcased = {}
end

Instance Method Details

#[](key) ⇒ Object



25
26
27
# File 'lib/excon/headers.rb', line 25

def [](key)
  @downcased[key.downcase]
end

#assoc(obj) ⇒ Object



36
37
38
# File 'lib/excon/headers.rb', line 36

def assoc(obj)
  @downcased.assoc(obj.downcase)
end

#delete(key, &proc) ⇒ Object



41
42
43
44
# File 'lib/excon/headers.rb', line 41

def delete(key, &proc)
  raw_delete(key, &proc)
  @downcased.delete(key.downcase, &proc)
end

#fetch(key, default = nil, &proc) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/excon/headers.rb', line 46

def fetch(key, default = nil, &proc)
  if proc
    @downcased.fetch(key.downcase, &proc)
  else
    @downcased.fetch(key.downcase, default)
  end
end

#raw_assocObject



9
# File 'lib/excon/headers.rb', line 9

alias_method :raw_assoc, :assoc

#raw_deleteObject



11
# File 'lib/excon/headers.rb', line 11

alias_method :raw_delete, :delete

#raw_fetchObject



12
# File 'lib/excon/headers.rb', line 12

alias_method :raw_fetch, :fetch

#raw_has_key?Object



13
# File 'lib/excon/headers.rb', line 13

alias_method :raw_has_key?, :has_key?

#raw_readerObject



7
# File 'lib/excon/headers.rb', line 7

alias_method :raw_reader, :[]

#raw_rehashObject



17
# File 'lib/excon/headers.rb', line 17

alias_method :raw_rehash, :rehash

#raw_values_atObject



19
# File 'lib/excon/headers.rb', line 19

alias_method :raw_values_at, :values_at

#raw_writerObject



6
# File 'lib/excon/headers.rb', line 6

alias_method :raw_writer, :[]=

#rehashObject



60
61
62
63
# File 'lib/excon/headers.rb', line 60

def rehash
  raw_rehash
  @downcased.rehash
end

#values_at(*keys) ⇒ Object



65
66
67
# File 'lib/excon/headers.rb', line 65

def values_at(*keys)
  @downcased.values_at(*keys.map {|key| key.downcase})
end