Class: Fauna::RequestResult
- Inherits:
-
Object
- Object
- Fauna::RequestResult
- Defined in:
- lib/fauna/request_result.rb
Overview
The result of a request. Provided to observers and included within errors.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
The Client.
-
#end_time ⇒ Object
readonly
Time the response was received.
-
#method ⇒ Object
readonly
HTTP method.
-
#path ⇒ Object
readonly
Path that was queried.
-
#query ⇒ Object
readonly
URL query.
-
#request_content ⇒ Object
readonly
Request data.
-
#response_content ⇒ Object
readonly
Parsed value returned by the server.
-
#response_headers ⇒ Object
readonly
A hash of headers.
-
#response_raw ⇒ Object
readonly
String value returned by the server.
-
#start_time ⇒ Object
readonly
Time the request started.
-
#status_code ⇒ Object
readonly
HTTP status code.
Instance Method Summary collapse
-
#auth ⇒ Object
Credentials used by the client.
-
#initialize(client, method, path, query, request_content, response_raw, response_content, status_code, response_headers, start_time, end_time) ⇒ RequestResult
constructor
A new instance of RequestResult.
-
#time_taken ⇒ Object
Real time spent performing the request.
Constructor Details
#initialize(client, method, path, query, request_content, response_raw, response_content, status_code, response_headers, start_time, end_time) ⇒ RequestResult
Returns a new instance of RequestResult.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fauna/request_result.rb', line 30 def initialize( client, method, path, query, request_content, response_raw, response_content, status_code, response_headers, start_time, end_time) # :nodoc: @client = client @method = method @path = path @query = query @request_content = request_content @response_raw = response_raw @response_content = response_content @status_code = status_code @response_headers = response_headers @start_time = start_time @end_time = end_time end |
Instance Attribute Details
#client ⇒ Object (readonly)
The Client.
5 6 7 |
# File 'lib/fauna/request_result.rb', line 5 def client @client end |
#end_time ⇒ Object (readonly)
Time the response was received.
28 29 30 |
# File 'lib/fauna/request_result.rb', line 28 def end_time @end_time end |
#method ⇒ Object (readonly)
HTTP method. Either :get
, :post
, :put
, :patch
, or :delete
7 8 9 |
# File 'lib/fauna/request_result.rb', line 7 def method @method end |
#path ⇒ Object (readonly)
Path that was queried. Relative to client’s domain.
9 10 11 |
# File 'lib/fauna/request_result.rb', line 9 def path @path end |
#query ⇒ Object (readonly)
URL query. nil
except for GET
requests.
11 12 13 |
# File 'lib/fauna/request_result.rb', line 11 def query @query end |
#request_content ⇒ Object (readonly)
Request data.
13 14 15 |
# File 'lib/fauna/request_result.rb', line 13 def request_content @request_content end |
#response_content ⇒ Object (readonly)
Parsed value returned by the server. Includes “resource” wrapper hash, or may be an “errors” hash instead. In the case of a JSON parse error, this will be nil.
20 21 22 |
# File 'lib/fauna/request_result.rb', line 20 def response_content @response_content end |
#response_headers ⇒ Object (readonly)
A hash of headers.
24 25 26 |
# File 'lib/fauna/request_result.rb', line 24 def response_headers @response_headers end |
#response_raw ⇒ Object (readonly)
String value returned by the server.
15 16 17 |
# File 'lib/fauna/request_result.rb', line 15 def response_raw @response_raw end |
#start_time ⇒ Object (readonly)
Time the request started.
26 27 28 |
# File 'lib/fauna/request_result.rb', line 26 def start_time @start_time end |
#status_code ⇒ Object (readonly)
HTTP status code.
22 23 24 |
# File 'lib/fauna/request_result.rb', line 22 def status_code @status_code end |
Instance Method Details
#auth ⇒ Object
Credentials used by the client.
54 55 56 |
# File 'lib/fauna/request_result.rb', line 54 def auth client.credentials end |
#time_taken ⇒ Object
Real time spent performing the request.
49 50 51 |
# File 'lib/fauna/request_result.rb', line 49 def time_taken end_time - start_time end |