Class: Pact::Headers
- Inherits:
-
Hash
- Object
- Hash
- Pact::Headers
- Defined in:
- lib/pact/consumer_contract/headers.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #fetch(*args, &block) ⇒ Object
-
#initialize(hash = {}) ⇒ Headers
constructor
A new instance of Headers.
- #key?(key) ⇒ Boolean (also: #has_key?, #include?)
Constructor Details
#initialize(hash = {}) ⇒ Headers
Returns a new instance of Headers.
8 9 10 11 12 13 14 |
# File 'lib/pact/consumer_contract/headers.rb', line 8 def initialize hash = {} hash.each_pair do | key, value | check_for_invalid key self[find_matching_key(key)] = value end self.freeze end |
Instance Method Details
#[](key) ⇒ Object
16 17 18 |
# File 'lib/pact/consumer_contract/headers.rb', line 16 def [] key super(find_matching_key(key)) end |
#fetch(*args, &block) ⇒ Object
20 21 22 23 |
# File 'lib/pact/consumer_contract/headers.rb', line 20 def fetch *args, &block args[0] = find_matching_key(args[0]) if args.first super(*args, &block) end |
#key?(key) ⇒ Boolean Also known as: has_key?, include?
25 26 27 |
# File 'lib/pact/consumer_contract/headers.rb', line 25 def key? key super(find_matching_key(key)) end |