class ActiveRecord::Relation
Public Instance Methods
delete_all(*args, &block)
click to toggle source
# File lib/undeletable.rb, line 61 def delete_all(*args, &block) if klass.respond_to?(:undeletable?) && klass.undeletable? raise ActiveRecord::ReadOnlyRecord.new("#{self} is undeletable") if klass.raise_on_delete? logger.debug("will not #{self}.delete_all", e) if Undeletable.debug else undeletable_orig_relation_delete_all(*args, &block) end end
Also aliased as: undeletable_orig_relation_delete_all
destroy_all(*args, &block)
click to toggle source
# File lib/undeletable.rb, line 72 def destroy_all(*args, &block) if klass.respond_to?(:undeletable?) && klass.undeletable? raise ActiveRecord::ReadOnlyRecord.new("#{self} is undeletable") if klass.raise_on_delete? logger.debug("will not #{self}.destroy_all", e) if Undeletable.debug if args.length > 0 && block_given? where(*args, &block).to_a.each {|object| object.run_callbacks(:destroy) { delete } }.tap { reset } elsif args.length > 0 && !block_given? where(*args).to_a.each {|object| object.run_callbacks(:destroy) { delete } }.tap { reset } elsif args.length == 0 && block_given? where(&block).to_a.each {|object| object.run_callbacks(:destroy) { delete } }.tap { reset } else to_a.each {|object| object.run_callbacks(:destroy) { delete } }.tap { reset } end else undeletable_orig_relation_destroy_all(*args, &block) end end
Also aliased as: undeletable_orig_relation_destroy_all
undeletable_orig_relation_delete_all(*args, &block)
don't use generic naming to try to avoid conflicts, since this isn't model class specific
Alias for: delete_all
undeletable_orig_relation_destroy_all(*args, &block)
don't use generic naming to try to avoid conflicts, since this isn't model class specific
Alias for: destroy_all