Class: Fauna::RequestResult

Inherits:
Object
  • Object
show all
Defined in:
lib/fauna/request_result.rb

Overview

The result of a request. Provided to observers and included within errors.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject (readonly)

The Client.



5
6
7
# File 'lib/fauna/request_result.rb', line 5

def client
  @client
end

#end_timeObject (readonly)

Time the response was received.



28
29
30
# File 'lib/fauna/request_result.rb', line 28

def end_time
  @end_time
end

#methodObject (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

#pathObject (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

#queryObject (readonly)

URL query. nil except for GET requests.



11
12
13
# File 'lib/fauna/request_result.rb', line 11

def query
  @query
end

#request_contentObject (readonly)

Request data.



13
14
15
# File 'lib/fauna/request_result.rb', line 13

def request_content
  @request_content
end

#response_contentObject (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_headersObject (readonly)

A hash of headers.



24
25
26
# File 'lib/fauna/request_result.rb', line 24

def response_headers
  @response_headers
end

#response_rawObject (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_timeObject (readonly)

Time the request started.



26
27
28
# File 'lib/fauna/request_result.rb', line 26

def start_time
  @start_time
end

#status_codeObject (readonly)

HTTP status code.



22
23
24
# File 'lib/fauna/request_result.rb', line 22

def status_code
  @status_code
end

Instance Method Details

#authObject

Credentials used by the client.



54
55
56
# File 'lib/fauna/request_result.rb', line 54

def auth
  client.credentials
end

#time_takenObject

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