lib/couchrest/model/extended_attachments.rb in couchrest_model-2.1.0.rc1 vs lib/couchrest/model/extended_attachments.rb in couchrest_model-2.2.0.beta1

- old
+ new

@@ -7,11 +7,11 @@ # :file and :name to be included in the arguments. def create_attachment(args={}) raise ArgumentError unless args[:file] && args[:name] return if has_attachment?(args[:name]) set_attachment_attr(args) - rescue ArgumentError => e + rescue ArgumentError raise ArgumentError, 'You must specify :file and :name' end # return all attachments def attachments @@ -27,19 +27,18 @@ def update_attachment(args={}) raise ArgumentError unless args[:file] && args[:name] return unless has_attachment?(args[:name]) delete_attachment(args[:name]) set_attachment_attr(args) - rescue ArgumentError => e + rescue ArgumentError raise ArgumentError, 'You must specify :file and :name' end # deletes a file attachment from the current doc def delete_attachment(attachment_name) return unless attachments if attachments.include?(attachment_name) - attribute_will_change!("_attachments") attachments.delete attachment_name end end # returns true if attachment_name exists @@ -69,10 +68,9 @@ def set_attachment_attr(args) content_type = args[:content_type] ? args[:content_type] : get_mime_type(args[:file].path) content_type ||= (get_mime_type(args[:name]) || 'text/plain') - attribute_will_change!("_attachments") attachments[args[:name]] = { 'content_type' => content_type, 'data' => args[:file].read } end