Module: Roar::HttpVerbs
- Included in:
- Client
- Defined in:
- lib/roar/http_verbs.rb
Overview
Gives HTTP-power to representers. They can serialize, send, process and deserialize HTTP-requests.
Defined Under Namespace
Modules: ClassMethods
Class Attribute Summary collapse
-
.transport_engine ⇒ Object
Returns the value of attribute transport_engine.
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #delete(options, &block) ⇒ Object
-
#get(options = {}, &block) ⇒ Object
GETs
url
withformat
, deserializes the returned document and updates properties accordingly. - #patch(options = {}, &block) ⇒ Object
-
#post(options = {}, &block) ⇒ Object
Serializes the object, POSTs it to
url
withformat
, deserializes the returned document and updates properties accordingly. -
#put(options = {}, &block) ⇒ Object
Serializes the object, PUTs it to
url
withformat
, deserializes the returned document and updates properties accordingly.
Class Attribute Details
.transport_engine ⇒ Object
Returns the value of attribute transport_engine.
8 9 10 |
# File 'lib/roar/http_verbs.rb', line 8 def transport_engine @transport_engine end |
Instance Attribute Details
#transport_engine ⇒ Object
26 27 28 |
# File 'lib/roar/http_verbs.rb', line 26 def transport_engine @transport_engine || HttpVerbs.transport_engine end |
Class Method Details
.included(base) ⇒ Object
10 11 12 |
# File 'lib/roar/http_verbs.rb', line 10 def included(base) base.extend ClassMethods end |
Instance Method Details
#delete(options, &block) ⇒ Object
57 58 59 60 |
# File 'lib/roar/http_verbs.rb', line 57 def delete(, &block) http.delete_uri(, &block) self end |
#get(options = {}, &block) ⇒ Object
GETs url
with format
, deserializes the returned document and updates properties accordingly.
38 39 40 41 |
# File 'lib/roar/http_verbs.rb', line 38 def get(={}, &block) response = http.get_uri(, &block) handle_response(response) end |
#patch(options = {}, &block) ⇒ Object
51 52 53 54 55 |
# File 'lib/roar/http_verbs.rb', line 51 def patch(={}, &block) response = http.patch_uri(.merge(:body => serialize), &block) handle_response(response) self end |
#post(options = {}, &block) ⇒ Object
Serializes the object, POSTs it to url
with format
, deserializes the returned document and updates properties accordingly.
32 33 34 35 |
# File 'lib/roar/http_verbs.rb', line 32 def post(={}, &block) response = http.post_uri(.merge(:body => serialize), &block) handle_response(response) end |
#put(options = {}, &block) ⇒ Object
Serializes the object, PUTs it to url
with format
, deserializes the returned document and updates properties accordingly.
45 46 47 48 49 |
# File 'lib/roar/http_verbs.rb', line 45 def put(={}, &block) response = http.put_uri(.merge(:body => serialize), &block) handle_response(response) self end |