Class: Praxis::Responses::MultipartOk
- Inherits:
-
Ok
- Object
- Praxis::Response
- Ok
- Praxis::Responses::MultipartOk
- Defined in:
- lib/praxis/responses/multipart_ok.rb
Instance Attribute Summary
Attributes inherited from Praxis::Response
#body, #headers, #name, #parts, #request, #status
Instance Method Summary collapse
- #encode! ⇒ Object
- #finish ⇒ Object
- #handle ⇒ Object
-
#initialize(status: self.class.status, headers: {}, body: '') ⇒ MultipartOk
constructor
A new instance of MultipartOk.
Methods inherited from Praxis::Response
#add_part, #content_type, #content_type=, #format!, inherited, #response_name, #validate
Constructor Details
#initialize(status: self.class.status, headers: {}, body: '') ⇒ MultipartOk
Returns a new instance of MultipartOk.
6 7 8 9 10 11 |
# File 'lib/praxis/responses/multipart_ok.rb', line 6 def initialize(status: self.class.status, headers: {}, body: '') @name = response_name @status = status @headers = headers @body = body end |
Instance Method Details
#encode! ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/praxis/responses/multipart_ok.rb', line 20 def encode! case @body when Praxis::Types::MultipartArray @body = @body.dump else super end end |
#finish ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/praxis/responses/multipart_ok.rb', line 29 def finish format! encode! @body = Array(@body) [@status, @headers, @body] end |
#handle ⇒ Object
13 14 15 16 17 18 |
# File 'lib/praxis/responses/multipart_ok.rb', line 13 def handle case @body when Praxis::Types::MultipartArray @headers['Content-Type'] = @body.content_type if @headers['Content-Type'].nil? end end |