Module: SoftDeletable::InstanceMethods
- Defined in:
- lib/soft-deletable.rb
Instance Method Summary collapse
Instance Method Details
#deleted? ⇒ Boolean
36 37 38 |
# File 'lib/soft-deletable.rb', line 36 def deleted? deleted_at.present? end |
#recover! ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/soft-deletable.rb', line 20 def recover! update_attribute :deleted_at, nil # recover all dependencies self.class.aasd_dependents.each do |assoc| self.send(assoc).unscoped.deleted.each do |r| r.recover! end end # recover all depends_on self.class.aasd_depends_on.each do |assoc| self.send(assoc).recover! if self.send(assoc).deleted? end end |
#soft_delete! ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/soft-deletable.rb', line 9 def soft_delete! update_attribute :deleted_at, Time.zone.now # soft_delete all dependencies (down the chain) self.class.aasd_dependents.each do |assoc| self.send(assoc).each do |r| r.soft_delete! end end end |