Class: ConoStorage::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/cono_storage/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(faraday_response) ⇒ Response



5
6
7
8
9
10
11
# File 'lib/cono_storage/response.rb', line 5

def initialize(faraday_response)
  @body    = faraday_response.body
  @headers = faraday_response.headers
  @status  = faraday_response.status
  @url     = faraday_response.env[:url].to_s
  @faraday_response = faraday_response
end

Instance Attribute Details

#faraday_responseObject

Returns the value of attribute faraday_response.



3
4
5
# File 'lib/cono_storage/response.rb', line 3

def faraday_response
  @faraday_response
end

Instance Method Details

#bodyHash, ...

Conostorage::Response#body



27
28
29
30
31
32
33
34
35
# File 'lib/cono_storage/response.rb', line 27

def body
  if @body and @body.size > 0
    JSON.parse(@body)
  else
    @body
  end
rescue JSON::ParserError
  @body
end

#headersHash

Conostorage::Response#headers



41
42
43
# File 'lib/cono_storage/response.rb', line 41

def headers
  @headers
end

#statusFixnum

Conostorage::Response#status



17
18
19
# File 'lib/cono_storage/response.rb', line 17

def status
  @status
end

#urlString

Conostorage::Response#url



49
50
51
# File 'lib/cono_storage/response.rb', line 49

def url
  @url
end