Class: Sofia::Types::Client::Headers
- Inherits:
-
Object
- Object
- Sofia::Types::Client::Headers
- Defined in:
- lib/sofia/types/client/headers.rb
Instance Method Summary collapse
-
#[](key) ⇒ Object
: (untyped key) -> void.
-
#[]=(key, value) ⇒ Object
: (untyped key, untyped value) -> void.
-
#each(&block) ⇒ Object
: () { ([String, String]) -> untyped } -> Hash[String, String].
-
#initialize(headers = {}) ⇒ Headers
constructor
: (?untyped headers) -> void.
-
#to_h ⇒ Object
: -> Hash[String, String].
Constructor Details
#initialize(headers = {}) ⇒ Headers
: (?untyped headers) -> void
10 11 12 13 14 |
# File 'lib/sofia/types/client/headers.rb', line 10 def initialize(headers = {}) defaults = { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } headers = validate_and_normalize(headers) @headers = defaults.merge(headers) #: Hash[String, String] end |
Instance Method Details
#[](key) ⇒ Object
: (untyped key) -> void
17 18 19 |
# File 'lib/sofia/types/client/headers.rb', line 17 def [](key) @headers[key.to_s] end |
#[]=(key, value) ⇒ Object
: (untyped key, untyped value) -> void
22 23 24 |
# File 'lib/sofia/types/client/headers.rb', line 22 def []=(key, value) @headers[key.to_s] = value.to_s end |
#each(&block) ⇒ Object
: () { ([String, String]) -> untyped } -> Hash[String, String]
32 33 34 |
# File 'lib/sofia/types/client/headers.rb', line 32 def each(&block) # rubocop:disable Naming/BlockForwarding @headers.each(&block) # rubocop:disable Naming/BlockForwarding end |
#to_h ⇒ Object
: -> Hash[String, String]
27 28 29 |
# File 'lib/sofia/types/client/headers.rb', line 27 def to_h @headers.dup end |