Module: CheckForDuplicateAttachedFile::ClassMethods
- Defined in:
- lib/paperclip_duplicate_check.rb
Overview
Methods added to the class.
Instance Method Summary collapse
-
#check_for_duplicate_attached_file(name, ...) ⇒ Object
Marks one or more attachments as performing duplicate checking.
Instance Method Details
#check_for_duplicate_attached_file(name, ...) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# 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| = send(name) old_fingerprint = .fingerprint super(file) if .fingerprint == old_fingerprint then # restore to saved state .instance_variable_set :@queued_for_delete, [] .instance_variable_set :@queued_for_write, {} .instance_variable_set :@errors, {} .instance_variable_set :@dirty, false end end end prepend extensions end |