forked from mattetti/couchrest
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
535 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module RestAPI | ||
|
||
def put(uri, doc = nil) | ||
payload = doc.to_json if doc | ||
begin | ||
JSON.parse(HttpAbstraction.put(uri, payload)) | ||
rescue Exception => e | ||
if $DEBUG | ||
raise "Error while sending a PUT request #{uri}\npayload: #{payload.inspect}\n#{e}" | ||
else | ||
raise e | ||
end | ||
end | ||
end | ||
|
||
def get(uri) | ||
begin | ||
JSON.parse(HttpAbstraction.get(uri), :max_nesting => false) | ||
rescue => e | ||
if $DEBUG | ||
raise "Error while sending a GET request #{uri}\n: #{e}" | ||
else | ||
raise e | ||
end | ||
end | ||
end | ||
|
||
def post(uri, doc = nil) | ||
payload = doc.to_json if doc | ||
begin | ||
JSON.parse(HttpAbstraction.post(uri, payload)) | ||
rescue Exception => e | ||
if $DEBUG | ||
raise "Error while sending a POST request #{uri}\npayload: #{payload.inspect}\n#{e}" | ||
else | ||
raise e | ||
end | ||
end | ||
end | ||
|
||
def delete(uri) | ||
JSON.parse(HttpAbstraction.delete(uri)) | ||
end | ||
|
||
def copy(uri, destination) | ||
JSON.parse(HttpAbstraction.copy(uri, {'Destination' => destination})) | ||
end | ||
|
||
end |
Oops, something went wrong.