Module: RockingChair::HttpAdapter
- Defined in:
- lib/rocking_chair/http_adapter.rb
Instance Method Summary collapse
- #copy(uri, destination) ⇒ Object
- #delete(uri, headers = nil) ⇒ Object
- #get(uri, headers = nil) ⇒ Object
- #http_adapter ⇒ Object
- #post(uri, payload, headers = nil) ⇒ Object
- #put(uri, payload = nil, headers = nil) ⇒ Object
Instance Method Details
#copy(uri, destination) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/rocking_chair/http_adapter.rb', line 55 def copy(uri, destination) result = http_adapter.copy(uri, default_headers.merge('Destination' => destination)) if result.is_a?(String) JSON.parse(result) else result end end |
#delete(uri, headers = nil) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/rocking_chair/http_adapter.rb', line 46 def delete(uri, headers=nil) result = http_adapter.delete(uri) if result.is_a?(String) JSON.parse(result) else result end end |
#get(uri, headers = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/rocking_chair/http_adapter.rb', line 19 def get(uri, headers=nil) result = http_adapter.get(uri) if result.is_a?(String) JSON.parse(result) else result end end |
#http_adapter ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rocking_chair/http_adapter.rb', line 6 def http_adapter unless @_restclient @_restclient = Object.new @_restclient.extend(RestAPI) end if RockingChair.enabled? RockingChair::CouchRestHttpAdapter else @_restclient end end |
#post(uri, payload, headers = nil) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/rocking_chair/http_adapter.rb', line 28 def post(uri, payload, headers=nil) result = http_adapter.post(uri, payload) if result.is_a?(String) JSON.parse(result) else result end end |
#put(uri, payload = nil, headers = nil) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/rocking_chair/http_adapter.rb', line 37 def put(uri, payload=nil, headers=nil) result = http_adapter.put(uri, payload) if result.is_a?(String) JSON.parse(result) else result end end |