Class: Opushon::Response Private
- Inherits:
-
Object
- Object
- Opushon::Response
- Defined in:
- lib/opushon/response.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #body ⇒ Object readonly private
- #headers ⇒ Object readonly private
Class Method Summary collapse
- .load(hash) ⇒ Object private
Instance Method Summary collapse
-
#initialize(headers: {}, body: {}) ⇒ Response
constructor
private
A new instance of Response.
- #to_h ⇒ Object private
Constructor Details
#initialize(headers: {}, body: {}) ⇒ Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Response.
23 24 25 26 27 28 29 |
# File 'lib/opushon/response.rb', line 23 def initialize(headers: {}, body: {}) raise ArgumentError, "headers #{headers.inspect}" unless headers.is_a?(Hash) raise ArgumentError, "body #{body.inspect}" unless body.is_a?(Hash) @headers = headers.map { |k, v| [k.to_sym, Parameter.load(v)] }.to_h @body = body.map { |k, v| [k.to_sym, Parameter.load(v)] }.to_h end |
Instance Attribute Details
#body ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/opushon/response.rb', line 21 def body @body end |
#headers ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/opushon/response.rb', line 21 def headers @headers end |
Class Method Details
.load(hash) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/opushon/response.rb', line 7 def self.load(hash) raise ArgumentError, "hash #{hash.inspect}" unless hash.is_a?(Hash) headers = hash.fetch('headers', nil) body = hash.fetch('body', nil) hash = { headers: headers, body: body }.compact new(**hash) end |
Instance Method Details
#to_h ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 35 36 |
# File 'lib/opushon/response.rb', line 31 def to_h { headers: headers.map { |k, v| [k, v.to_h] }.to_h, body: body.map { |k, v| [k, v.to_h] }.to_h } end |