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
Constructor Details
#initialize(client, request_method, path, options = {}) ⇒ Uber::ApiRequest
12 13 14 15 16 17 |
# File 'lib/uber/api_request.rb', line 12 def initialize(client, request_method, path, = {}) @client = client @request_method = request_method.to_sym @path = path = end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/uber/api_request.rb', line 4 def client @client end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/uber/api_request.rb', line 4 def end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/uber/api_request.rb', line 4 def path @path end |
#request_method ⇒ Object Also known as: verb
Returns the value of attribute request_method.
4 5 6 |
# File 'lib/uber/api_request.rb', line 4 def request_method @request_method end |
Instance Method Details
#perform ⇒ Hash
20 21 22 |
# File 'lib/uber/api_request.rb', line 20 def perform @client.send(@request_method, @path, ).body end |
#perform_with_object(klass) ⇒ Object
27 28 29 |
# File 'lib/uber/api_request.rb', line 27 def perform_with_object(klass) klass.new(perform) end |
#perform_with_objects(klass) ⇒ Array
33 34 35 36 37 |
# File 'lib/uber/api_request.rb', line 33 def perform_with_objects(klass) perform.values.flatten.map do |element| klass.new(element) end end |