Class: Excon::Headers

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

Constant Summary collapse

SENTINEL =
{}

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/excon/headers.rb', line 21

def [](key)
  if should_delegate?(key)
    @downcased[key.downcase]
  else
    raw_reader(key)
  end
end

#assoc(obj) ⇒ Object



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

def assoc(obj)
  if should_delegate?(obj)
    @downcased.assoc(obj.downcase)
  else
    raw_assoc(obj)
  end
end

#delete(key, &proc) ⇒ Object



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

def delete(key, &proc)
  if should_delegate?(key)
    @downcased.delete(key.downcase, &proc)
  else
    raw_delete(key, &proc)
  end
end

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



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/excon/headers.rb', line 55

def fetch(key, default = nil, &proc)
  if should_delegate?(key)
    if proc
      @downcased.fetch(key.downcase, &proc)
    else
      @downcased.fetch(key.downcase, default)
    end
  else
    if proc
      raw_fetch(key, &proc)
    else
      raw_fetch(key, default)
    end
  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



80
81
82
83
84
85
# File 'lib/excon/headers.rb', line 80

def rehash
  raw_rehash
  if @downcased
    @downcased.rehash
  end
end

#values_at(*keys) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/excon/headers.rb', line 87

def values_at(*keys)
  raw_values_at(*keys).zip(keys).map do |v, k|
    if v.nil?
      index_case_insensitive
      @downcased[k.downcase]
    end
  end
end