Module: CouchRest::Attachments
- Included in:
- Document
- Defined in:
- lib/couchrest/helper/attachments.rb
Instance Method Summary collapse
-
#delete_attachment(name, force = false) ⇒ Object
deletes an attachment directly from couchdb.
-
#fetch_attachment(name) ⇒ Object
returns an attachment’s data.
-
#put_attachment(name, file, options = {}) ⇒ Object
saves an attachment directly to couchdb.
Instance Method Details
#delete_attachment(name, force = false) ⇒ Object
deletes an attachment directly from couchdb
21 22 23 24 25 26 |
# File 'lib/couchrest/helper/attachments.rb', line 21 def (name, force=false) raise ArgumentError, "doc.database required to delete_attachment" unless database result = database.(self, name, force) self['_rev'] = result['rev'] result['ok'] end |
#fetch_attachment(name) ⇒ Object
returns an attachment’s data
14 15 16 17 18 |
# File 'lib/couchrest/helper/attachments.rb', line 14 def (name) raise ArgumentError, "doc must be saved" unless self.rev raise ArgumentError, "doc.database required to put_attachment" unless database database.(self, name) end |
#put_attachment(name, file, options = {}) ⇒ Object
saves an attachment directly to couchdb
5 6 7 8 9 10 11 |
# File 'lib/couchrest/helper/attachments.rb', line 5 def (name, file, ={}) raise ArgumentError, "doc must be saved" unless self.rev raise ArgumentError, "doc.database required to put_attachment" unless database result = database.(self, name, file, ) self['_rev'] = result['rev'] result['ok'] end |