Class: Opushon::Request Private
- Inherits:
-
Object
- Object
- Opushon::Request
- Defined in:
- lib/opushon/request.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
- #query_string ⇒ Object readonly private
Class Method Summary collapse
- .load(hash) ⇒ Object private
Instance Method Summary collapse
-
#initialize(headers: {}, query_string: {}, body: {}) ⇒ Request
constructor
private
A new instance of Request.
- #to_h ⇒ Object private
Constructor Details
#initialize(headers: {}, query_string: {}, body: {}) ⇒ Request
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 Request.
25 26 27 28 29 30 31 32 33 |
# File 'lib/opushon/request.rb', line 25 def initialize(headers: {}, query_string: {}, body: {}) raise ArgumentError, "headers #{headers.inspect}" unless headers.is_a?(Hash) raise ArgumentError, "query_string #{query_string.inspect}" unless query_string.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 @query_string = query_string.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.
23 24 25 |
# File 'lib/opushon/request.rb', line 23 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.
23 24 25 |
# File 'lib/opushon/request.rb', line 23 def headers @headers end |
#query_string ⇒ 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.
23 24 25 |
# File 'lib/opushon/request.rb', line 23 def query_string @query_string 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 20 21 |
# File 'lib/opushon/request.rb', line 7 def self.load(hash) raise ArgumentError, "hash #{hash.inspect}" unless hash.is_a?(Hash) headers = hash.fetch('headers', nil) query_string = hash.fetch('query_string', nil) body = hash.fetch('body', nil) hash = { headers: headers, query_string: query_string, 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.
35 36 37 38 39 40 41 |
# File 'lib/opushon/request.rb', line 35 def to_h { headers: headers.map { |k, v| [k, v.to_h] }.to_h, query_string: query_string.map { |k, v| [k, v.to_h] }.to_h, body: body.map { |k, v| [k, v.to_h] }.to_h } end |