Class: Protocol::HTTP::Headers::Merged
- Inherits:
-
Object
- Object
- Protocol::HTTP::Headers::Merged
- Includes:
- Enumerable
- Defined in:
- lib/protocol/http/headers.rb
Overview
Used for merging objects into a sequential list of headers. Normalizes header keys and values.
Instance Method Summary collapse
- #<<(headers) ⇒ Object
- #clear ⇒ Object
- #each(&block) ⇒ Object
- #fields ⇒ Object
- #flatten ⇒ Object
-
#initialize(*all) ⇒ Merged
constructor
A new instance of Merged.
Constructor Details
#initialize(*all) ⇒ Merged
Returns a new instance of Merged.
323 324 325 |
# File 'lib/protocol/http/headers.rb', line 323 def initialize(*all) @all = all end |
Instance Method Details
#<<(headers) ⇒ Object
339 340 341 342 343 |
# File 'lib/protocol/http/headers.rb', line 339 def << headers @all << headers return self end |
#clear ⇒ Object
335 336 337 |
# File 'lib/protocol/http/headers.rb', line 335 def clear @all.clear end |
#each(&block) ⇒ Object
346 347 348 349 350 351 352 353 354 |
# File 'lib/protocol/http/headers.rb', line 346 def each(&block) return to_enum unless block_given? @all.each do |headers| headers.each do |key, value| yield key.to_s.downcase, value.to_s end end end |
#fields ⇒ Object
327 328 329 |
# File 'lib/protocol/http/headers.rb', line 327 def fields each.to_a end |
#flatten ⇒ Object
331 332 333 |
# File 'lib/protocol/http/headers.rb', line 331 def flatten Headers.new(fields) end |