Class: Strobe::Resources::Application::Multipart
- Inherits:
-
Object
- Object
- Strobe::Resources::Application::Multipart
- Defined in:
- lib/strobe/resources/application.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #body ⇒ Object
- #file(path, content_type, body) ⇒ Object
- #headers ⇒ Object
-
#initialize(params) {|_self| ... } ⇒ Multipart
constructor
A new instance of Multipart.
Constructor Details
#initialize(params) {|_self| ... } ⇒ Multipart
Returns a new instance of Multipart.
79 80 81 82 83 84 |
# File 'lib/strobe/resources/application.rb', line 79 def initialize(params) @params = params @files = [] yield self if block_given? end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
77 78 79 |
# File 'lib/strobe/resources/application.rb', line 77 def params @params end |
Instance Method Details
#body ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/strobe/resources/application.rb', line 94 def body b = "--#{boundary}\r\n" b << part("metadata", "application/json", ) b << "--#{boundary}\r\n" @files.each do |path, type, body| b << part("files[]", type, body) b << "--#{boundary}\r\n" end b end |
#file(path, content_type, body) ⇒ Object
86 87 88 |
# File 'lib/strobe/resources/application.rb', line 86 def file(path, content_type, body) @files << [path, content_type, body] end |
#headers ⇒ Object
90 91 92 |
# File 'lib/strobe/resources/application.rb', line 90 def headers { "Content-Type" => %[multipart/form-data; boundary="#{boundary}"] } end |