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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.transport_engineObject

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_engineObject



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(options, &block)
  http.delete_uri(options, &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(options={}, &block)
  response = http.get_uri(options, &block)
  handle_response(response)
end

#patch(options = {}, &block) ⇒ Object



51
52
53
54
55
# 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) ⇒ 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(options={}, &block)
  response = http.post_uri(options.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(options={}, &block)
  response = http.put_uri(options.merge(:body => serialize), &block)
  handle_response(response)
  self
end