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
Add a new set of headers to the merged list.
-
#clear ⇒ Object
Clear the references to all headers.
-
#each(&block) ⇒ Object
Enumerate all headers in the merged list.
- #fields ⇒ Object
- #flatten ⇒ Object
-
#initialize(*all) ⇒ Merged
constructor
Construct a merged list of headers.
Constructor Details
#initialize(*all) ⇒ Merged
Construct a merged list of headers.
483 484 485 |
# File 'lib/protocol/http/headers.rb', line 483 def initialize(*all) @all = all end |
Instance Method Details
#<<(headers) ⇒ Object
Add a new set of headers to the merged list.
505 506 507 508 509 |
# File 'lib/protocol/http/headers.rb', line 505 def << headers @all << headers return self end |
#clear ⇒ Object
Clear the references to all headers.
498 499 500 |
# File 'lib/protocol/http/headers.rb', line 498 def clear @all.clear end |
#each(&block) ⇒ Object
Enumerate all headers in the merged list.
516 517 518 519 520 521 522 523 524 |
# File 'lib/protocol/http/headers.rb', line 516 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
488 489 490 |
# File 'lib/protocol/http/headers.rb', line 488 def fields each.to_a end |
#flatten ⇒ Object
493 494 495 |
# File 'lib/protocol/http/headers.rb', line 493 def flatten Headers.new(fields) end |