module CheckForDuplicateAttachedFile::ClassMethods
Methods added to the class.
Public Instance Methods
check_for_duplicate_attached_file(*names)
click to toggle source
@overload check_for_duplicate_attached_file
(name, …)
Marks one or more attachments as performing duplicate checking. @param [Symbol] name An attachment name.
Calls superclass method
# File lib/paperclip_duplicate_check.rb, line 21 def check_for_duplicate_attached_file(*names) extensions = Module.new names.each do |name| extensions.send :define_method, :"#{name}=" do |file| attachment = send(name) old_fingerprint = attachment.fingerprint super(file) if attachment.fingerprint == old_fingerprint then # restore to saved state attachment.instance_variable_set :@queued_for_delete, [] attachment.instance_variable_set :@queued_for_write, {} attachment.instance_variable_set :@errors, {} attachment.instance_variable_set :@dirty, false end end end prepend extensions end