Module: DeleteParanoid::ClassMethods
- Defined in:
- lib/delete_paranoid.rb
Instance Method Summary collapse
- #delete_all(conditions = nil) ⇒ Object
- #destroy_all!(conditions = nil) ⇒ Object
- #with_deleted ⇒ Object
Instance Method Details
#delete_all(conditions = nil) ⇒ Object
23 24 25 |
# File 'lib/delete_paranoid.rb', line 23 def delete_all(conditions = nil) update_all ["deleted_at = ?", Time.now.utc], conditions end |
#destroy_all!(conditions = nil) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/delete_paranoid.rb', line 27 def destroy_all!(conditions = nil) if conditions where(conditions).destroy_all! else to_a.each {|object| object.destroy! }.tap { reset } end end |
#with_deleted ⇒ Object
17 18 19 20 21 |
# File 'lib/delete_paranoid.rb', line 17 def with_deleted self.unscoped do yield end end |