Class: SimpleMapper::HttpAdapter
Instance Attribute Summary collapse
Instance Method Summary
collapse
#add_callback, #callbacks, #run_callback
#oauth, #requires_oauth, #set_oauth, with_oauth
Instance Attribute Details
Returns the value of attribute base_url.
14
15
16
|
# File 'lib/simple_mapper/adapters/http_adapter.rb', line 14
def base_url
@base_url
end
|
Instance Method Details
16
17
18
|
# File 'lib/simple_mapper/adapters/http_adapter.rb', line 16
def base_uri
URI.parse(base_url)
end
|
#delete(identifier) ⇒ Object
In the http adapter, the identifier is a url.
43
44
45
|
# File 'lib/simple_mapper/adapters/http_adapter.rb', line 43
def delete(identifier)
http.request(request('delete', URI.parse(identifier).path)).body
end
|
#get(find_options = {}) ⇒ Object
29
30
31
32
|
# File 'lib/simple_mapper/adapters/http_adapter.rb', line 29
def get(find_options={})
query = find_options.empty? ? '' : ('?' + find_options.to_query)
http.request(request('get', base_uri.path + query)).body
end
|
20
21
22
|
# File 'lib/simple_mapper/adapters/http_adapter.rb', line 20
def
@headers ||= {}
end
|
23
24
25
26
|
# File 'lib/simple_mapper/adapters/http_adapter.rb', line 23
def (v)
raise TypeError, "headers set must be a hash" unless v.is_a?(Hash)
.merge!(v)
end
|
#post(data) ⇒ Object
38
39
40
|
# File 'lib/simple_mapper/adapters/http_adapter.rb', line 38
def post(data)
http.request(request('post', base_uri.path, data)).body
end
|
#put(identifier, data) ⇒ Object
34
35
36
|
# File 'lib/simple_mapper/adapters/http_adapter.rb', line 34
def put(identifier,data)
http.request(request('put', URI.parse(identifier).path, data)).body
end
|