Class: Magellan::Rails::Response
- Inherits:
-
Object
- Object
- Magellan::Rails::Response
- Defined in:
- lib/magellan/rails/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#body_encoding ⇒ Object
Returns the value of attribute body_encoding.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
9 10 11 |
# File 'lib/magellan/rails/response.rb', line 9 def body @body end |
#body_encoding ⇒ Object
Returns the value of attribute body_encoding.
9 10 11 |
# File 'lib/magellan/rails/response.rb', line 9 def body_encoding @body_encoding end |
#headers ⇒ Object
Returns the value of attribute headers.
9 10 11 |
# File 'lib/magellan/rails/response.rb', line 9 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status.
9 10 11 |
# File 'lib/magellan/rails/response.rb', line 9 def status @status end |
Instance Method Details
#parse_rack_response(response) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/magellan/rails/response.rb', line 11 def parse_rack_response(response) @status = response[0] @headers = response[1] @body = '' @body_encoding = :plain body_proxy = response[2] begin body_proxy.each{|b| @body << b} ensure body_proxy.close if body_proxy.respond_to?(:close) end end |
#to_message ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/magellan/rails/response.rb', line 24 def json_generate_errors = [JSON::GeneratorError, Encoding::UndefinedConversionError] begin { headers: @headers, status: @status, body: @body, body_encoding: @body_encoding.to_s, }.to_msgpack rescue *json_generate_errors @body = Base64.strict_encode64(@body) @body_encoding = :base64 end end |