Class: ChefAPI::Multipart::Body
- Inherits:
-
Object
- Object
- ChefAPI::Multipart::Body
- Defined in:
- lib/chef-api/connection.rb
Instance Method Summary collapse
- #content_length ⇒ Object
- #content_type ⇒ Object
-
#initialize(params = {}) ⇒ Body
constructor
A new instance of Body.
- #stream ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Body
Returns a new instance of Body.
523 524 525 526 527 528 529 530 531 532 533 |
# File 'lib/chef-api/connection.rb', line 523 def initialize(params = {}) params.each do |key, value| if value.respond_to?(:read) parts << FilePart.new(key, value) else parts << ParamPart.new(key, value) end end parts << EndingPart.new end |
Instance Method Details
#content_length ⇒ Object
543 544 545 |
# File 'lib/chef-api/connection.rb', line 543 def content_length parts.map(&:size).inject(:+) end |
#content_type ⇒ Object
539 540 541 |
# File 'lib/chef-api/connection.rb', line 539 def content_type "multipart/form-data; boundary=#{BOUNDARY}" end |
#stream ⇒ Object
535 536 537 |
# File 'lib/chef-api/connection.rb', line 535 def stream MultiIO.new(*parts.map(&:io)) end |