module Roar::HttpVerbs
Gives HTTP-power to representers. They can serialize, send, process and deserialize HTTP-requests.
Attributes
transport_engine[RW]
transport_engine[W]
Public Class Methods
included(base)
click to toggle source
# File lib/roar/http_verbs.rb, line 10 def included(base) base.extend ClassMethods end
Public Instance Methods
delete(options, &block)
click to toggle source
# File lib/roar/http_verbs.rb, line 57 def delete(options, &block) http.delete_uri(options, &block) self end
get(options={}, &block)
click to toggle source
GETs url
with format
, deserializes the returned document and updates properties accordingly.
# File lib/roar/http_verbs.rb, line 38 def get(options={}, &block) response = http.get_uri(options, &block) handle_response(response) end
patch(options={}, &block)
click to toggle source
# File lib/roar/http_verbs.rb, line 51 def patch(options={}, &block) response = http.patch_uri(options.merge(:body => serialize), &block) handle_response(response) self end
post(options={}, &block)
click to toggle source
Serializes the object, POSTs it to url
with format
, deserializes the returned document and updates properties accordingly.
# File lib/roar/http_verbs.rb, line 32 def post(options={}, &block) response = http.post_uri(options.merge(:body => serialize), &block) handle_response(response) end
put(options={}, &block)
click to toggle source
Serializes the object, PUTs it to url
with format
, deserializes the returned document and updates properties accordingly.
# File lib/roar/http_verbs.rb, line 45 def put(options={}, &block) response = http.put_uri(options.merge(:body => serialize), &block) handle_response(response) self end
transport_engine()
click to toggle source
# File lib/roar/http_verbs.rb, line 26 def transport_engine @transport_engine || HttpVerbs.transport_engine end
Private Instance Methods
handle_response(response)
click to toggle source
# File lib/roar/http_verbs.rb, line 63 def handle_response(response) document = response.body deserialize(document) end
http()
click to toggle source
# File lib/roar/http_verbs.rb, line 68 def http transport_engine.new end