Class: Typhoeus::NormalizedHeaderHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/typhoeus/normalized_header_hash.rb

Instance Method Summary collapse

Constructor Details

#initialize(constructor = {}) ⇒ NormalizedHeaderHash

Returns a new instance of NormalizedHeaderHash.



3
4
5
6
7
8
9
10
# File 'lib/typhoeus/normalized_header_hash.rb', line 3

def initialize(constructor = {})
  if constructor.is_a?(Hash)
    super
    update(constructor)
  else
    super(constructor)
  end
end

Instance Method Details

#[](key) ⇒ Object



24
25
26
# File 'lib/typhoeus/normalized_header_hash.rb', line 24

def [](key)
  super(convert_key(key))
end

#[]=(key, value) ⇒ Object



28
29
30
# File 'lib/typhoeus/normalized_header_hash.rb', line 28

def []=(key, value)
  super(convert_key(key), value)
end

#delete(key) ⇒ Object



49
50
51
# File 'lib/typhoeus/normalized_header_hash.rb', line 49

def delete(key)
  super(convert_key(key))
end

#dupObject



41
42
43
# File 'lib/typhoeus/normalized_header_hash.rb', line 41

def dup
  self.class.new(self)
end

#fetch(key, *extras) ⇒ Object



12
13
14
# File 'lib/typhoeus/normalized_header_hash.rb', line 12

def fetch(key, *extras)
  super(convert_key(key), *extras)
end

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/typhoeus/normalized_header_hash.rb', line 16

def key?(key)
  super(convert_key(key))
end

#merge(hash) ⇒ Object



45
46
47
# File 'lib/typhoeus/normalized_header_hash.rb', line 45

def merge(hash)
  self.dup.update(hash)
end

#update(other_hash) ⇒ Object Also known as: merge!



32
33
34
35
36
37
# File 'lib/typhoeus/normalized_header_hash.rb', line 32

def update(other_hash)
  other_hash.each_pair do |key, value|
    self[convert_key(key)] = value
  end
  self
end