Module: CheckForDuplicateAttachedFile::ClassMethods
- Defined in:
- lib/paperclip_duplicate_check.rb
Overview
Methods added to the class.
Instance Method Summary (collapse)
-
- (Object) check_for_duplicate_attached_file(name, ...)
Marks one or more attachments as performing duplicate checking.
Instance Method Details
- (Object) check_for_duplicate_attached_file(name, ...)
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/paperclip_duplicate_check.rb', line 21 def check_for_duplicate_attached_file(*names) names.each do |name| define_method :#{name}_with_dup_check=" do |file| = send(name) old_fingerprint = .fingerprint send :#{name}_without_dup_check=", 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 alias_method_chain :#{name}=", :dup_check end end |