Sha256: fcf00885b5f19009195b0ae24f1ff07c222116b786b6903003480145e3331d47

Contents?: true

Size: 1.02 KB

Versions: 65

Compression:

Stored size: 1.02 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)
        raise ArgumentError, "doc.database required to delete_attachment" unless database
        result = database.delete_attachment(self, name)
        self['_rev'] = result['rev']
        result['ok']
      end
    
    end
  end
end

Version data entries

65 entries across 65 versions & 20 rubygems

Version Path
brianmario-couchrest-0.23 lib/couchrest/mixins/attachments.rb
gbuesing-couchrest-0.23 lib/couchrest/mixins/attachments.rb
glasner-couchrest-0.2.2 lib/couchrest/mixins/attachments.rb
gohanlonllc-couchrest-0.2.3.1 lib/couchrest/mixins/attachments.rb
halfninja-couchrest-0.23.2 lib/couchrest/mixins/attachments.rb
halfninja-couchrest-0.23.3 lib/couchrest/mixins/attachments.rb
jchris-couchrest-0.16 lib/couchrest/mixins/attachments.rb
jchris-couchrest-0.17.0 lib/couchrest/mixins/attachments.rb
jchris-couchrest-0.2.1 lib/couchrest/mixins/attachments.rb
jchris-couchrest-0.2.2 lib/couchrest/mixins/attachments.rb
jchris-couchrest-0.2 lib/couchrest/mixins/attachments.rb
jchris-couchrest-0.22 lib/couchrest/mixins/attachments.rb
jchris-couchrest-0.23 lib/couchrest/mixins/attachments.rb
jkestr-couchrest-0.23 lib/couchrest/mixins/attachments.rb
jpbougie-couchrest-0.27 lib/couchrest/mixins/attachments.rb
jrun-couchrest-0.17.1 lib/couchrest/mixins/attachments.rb
jrun-couchrest-0.2.1.1 lib/couchrest/mixins/attachments.rb
jrun-couchrest-0.2.1 lib/couchrest/mixins/attachments.rb
mattetti-couchrest-0.13.1 lib/couchrest/mixins/attachments.rb
mattetti-couchrest-0.13.2 lib/couchrest/mixins/attachments.rb