Module: Restfulie::Client::HTTP::ResponseHolder

Defined in:
lib/restfulie/client/http/response_holder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



3
4
5
# File 'lib/restfulie/client/http/response_holder.rb', line 3

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/restfulie/client/http/response_holder.rb', line 3

def response
  @response
end

Instance Method Details

#at(uri) ⇒ Object



11
12
13
# File 'lib/restfulie/client/http/response_holder.rb', line 11

def at(uri)
  request.clone.at(uri)
end

#headersObject



15
16
17
# File 'lib/restfulie/client/http/response_holder.rb', line 15

def headers
  response.to_hash.extend(::Restfulie::Client::HTTP::LinkHeader)
end

#resourceObject



5
6
7
8
9
# File 'lib/restfulie/client/http/response_holder.rb', line 5

def resource
  type = headers['content-type'] || response['Content-Type']
  representation = Medie.registry.for(type[0])
  representation.unmarshal(response.body)
end

#results_from(request, response) ⇒ Object



19
20
21
22
# File 'lib/restfulie/client/http/response_holder.rb', line 19

def results_from(request, response)
  @request = request
  @response = response
end

#verbObject



24
25
26
# File 'lib/restfulie/client/http/response_holder.rb', line 24

def verb
  @request.verb
end