Class: ChefAPI::Multipart::Body
- Inherits:
-
Object
- Object
- ChefAPI::Multipart::Body
- Defined in:
- lib/chef-api/multipart.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.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/chef-api/multipart.rb', line 9 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
29 30 31 |
# File 'lib/chef-api/multipart.rb', line 29 def content_length parts.map(&:size).inject(:+) end |
#content_type ⇒ Object
25 26 27 |
# File 'lib/chef-api/multipart.rb', line 25 def content_type "multipart/form-data; boundary=#{BOUNDARY}" end |