Sha256: 72290820c068b97406d3ff2f1c8ffa9e585b38c19d43023faa22bf8b947d28a1

Contents?: true

Size: 1.04 KB

Versions: 21

Compression:

Stored size: 1.04 KB

Contents

module CouchRest
  module Mixins
    module Attachments
    
      # saves an attachment directly to couchdb
      def put_attachment(name, file, options={})
        raise ArgumentError, "doc must be saved" unless self.rev
        raise ArgumentError, "doc.database required to put_attachment" unless database
        result = database.put_attachment(self, name, file, options)
        self['_rev'] = result['rev']
        result['ok']
      end

      # returns an attachment's data
      def fetch_attachment(name)
        raise ArgumentError, "doc must be saved" unless self.rev
        raise ArgumentError, "doc.database required to put_attachment" unless database
        database.fetch_attachment(self, name)
      end

      # deletes an attachment directly from couchdb
      def delete_attachment(name, force=false)
        raise ArgumentError, "doc.database required to delete_attachment" unless database
        result = database.delete_attachment(self, name, force)
        self['_rev'] = result['rev']
        result['ok']
      end
    
    end
  end
end

Version data entries

21 entries across 21 versions & 7 rubygems

Version Path
mattetti-couchrest-0.33 lib/couchrest/mixins/attachments.rb
mattetti-couchrest-0.34 lib/couchrest/mixins/attachments.rb
norr-couchrest-0.33.01 lib/couchrest/mixins/attachments.rb
norr-couchrest-0.33.02 lib/couchrest/mixins/attachments.rb
norr-couchrest-0.33.06 lib/couchrest/mixins/attachments.rb
norr-couchrest-0.33.07 lib/couchrest/mixins/attachments.rb
peterpunk-couchrest-0.33 lib/couchrest/mixins/attachments.rb
peterpunk-couchrest-0.34.1 lib/couchrest/mixins/attachments.rb
sporkd-couchrest-0.33 lib/couchrest/mixins/attachments.rb
sporkd-couchrest-0.34 lib/couchrest/mixins/attachments.rb
will-couchrest-0.33.1 lib/couchrest/mixins/attachments.rb
will-couchrest-0.33 lib/couchrest/mixins/attachments.rb
couchrest-0.38 lib/couchrest/mixins/attachments.rb
samlown-couchrest-0.37.2 lib/couchrest/mixins/attachments.rb
samlown-couchrest-0.37.1 lib/couchrest/mixins/attachments.rb
samlown-couchrest-0.35 lib/couchrest/mixins/attachments.rb
couchrest-0.37 lib/couchrest/mixins/attachments.rb
couchrest-0.36 lib/couchrest/mixins/attachments.rb
couchrest-0.35 lib/couchrest/mixins/attachments.rb
couchrest-0.34 lib/couchrest/mixins/attachments.rb