Class: Uber::ApiRequest
- Inherits:
-
Object
- Object
- Uber::ApiRequest
- Defined in:
- lib/uber/api_request.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#options ⇒ Object
Returns the value of attribute options.
-
#path ⇒ Object
Returns the value of attribute path.
-
#request_method ⇒ Object
(also: #verb)
Returns the value of attribute request_method.
Instance Method Summary collapse
- #initialize(client, request_method, path, options = {}) ⇒ Uber::ApiRequest constructor
- #perform ⇒ Hash
- #perform_with_object(klass) ⇒ Object
- #perform_with_objects(klass) ⇒ Array
- #perform_without_object ⇒ Object
Constructor Details
#initialize(client, request_method, path, options = {}) ⇒ Uber::ApiRequest
11 12 13 14 15 16 |
# File 'lib/uber/api_request.rb', line 11 def initialize(client, request_method, path, = {}) @client = client @request_method = request_method.to_sym @path = path @options = end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
3 4 5 |
# File 'lib/uber/api_request.rb', line 3 def client @client end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/uber/api_request.rb', line 3 def @options end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/uber/api_request.rb', line 3 def path @path end |
#request_method ⇒ Object Also known as: verb
Returns the value of attribute request_method.
3 4 5 |
# File 'lib/uber/api_request.rb', line 3 def request_method @request_method end |
Instance Method Details
#perform ⇒ Hash
19 20 21 |
# File 'lib/uber/api_request.rb', line 19 def perform @client.send(@request_method, @path, @options).body end |
#perform_with_object(klass) ⇒ Object
26 27 28 |
# File 'lib/uber/api_request.rb', line 26 def perform_with_object(klass) klass.new(perform) end |
#perform_with_objects(klass) ⇒ Array
32 33 34 35 36 |
# File 'lib/uber/api_request.rb', line 32 def perform_with_objects(klass) ((perform.values.find { |v| v.is_a?(Array) }) || []).collect do |element| klass.new(element) end end |
#perform_without_object ⇒ Object
39 40 41 |
# File 'lib/uber/api_request.rb', line 39 def perform_without_object @client.send(@request_method, @path, @options).status end |