Module: Ohmage::API::Document
- Included in:
- Ohmage::API
- Defined in:
- lib/ohmage/document.rb
Instance Method Summary collapse
-
#document_contents(params = {}) ⇒ Object
ohmage document/read/contents call.
-
#document_create(params = {}) ⇒ Object
ohmage document/create call.
-
#document_delete(params = {}) ⇒ Object
ohmage document/delete call.
-
#document_read(params = {}) ⇒ Object
ohmage document/read call.
-
#document_update(params = {}) ⇒ Object
ohmage document/update call.
Instance Method Details
#document_contents(params = {}) ⇒ Object
ohmage document/read/contents call
57 58 59 60 |
# File 'lib/ohmage/document.rb', line 57 def document_contents(params = {}) request = Ohmage::Request.new(self, :post, 'document/read/contents', params) request.perform end |
#document_create(params = {}) ⇒ Object
ohmage document/create call
23 24 25 26 27 28 29 |
# File 'lib/ohmage/document.rb', line 23 def document_create(params = {}) params[:document] = HTTP::FormData::File.new(params[:document]) # catch lack of document_name param, since we can just append the filename we have! request = Ohmage::Request.new(self, :post, 'document/create', params) request.perform document_read(document_name_search: params[:document_name]) end |
#document_delete(params = {}) ⇒ Object
ohmage document/delete call
47 48 49 50 |
# File 'lib/ohmage/document.rb', line 47 def document_delete(params = {}) request = Ohmage::Request.new(self, :post, 'document/delete', params) request.perform end |
#document_read(params = {}) ⇒ Object
ohmage document/read call
8 9 10 11 12 13 14 15 16 |
# File 'lib/ohmage/document.rb', line 8 def document_read(params = {}) request = Ohmage::Request.new(self, :post, 'document/read', params) # TODO: make a utility to abstract creation of array of base objects t = [] request.perform[:data].each do |k, v| t << Ohmage::Document.new(k => v) end t end |
#document_update(params = {}) ⇒ Object
ohmage document/update call
36 37 38 39 40 |
# File 'lib/ohmage/document.rb', line 36 def document_update(params = {}) params[:document] = HTTP::FormData::File.new(params[:document]) if params[:document] request = Ohmage::Request.new(self, :post, 'document/update', params) request.perform end |