Module: Cloudelete::ActiveRecord::InstanceMethods
- Defined in:
- lib/cloudelete.rb
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
- #delete_or_not ⇒ Object
- #deleted? ⇒ Boolean
- #destroy ⇒ Object
- #destroy! ⇒ Object
- #restore ⇒ Object
Class Method Details
.included(base) ⇒ Object
19 20 21 22 |
# File 'lib/cloudelete.rb', line 19 def self.included(base) base.send :alias_method, :delete!, :delete base.send :before_destroy, :delete_or_not end |
Instance Method Details
#delete ⇒ Object
33 34 35 |
# File 'lib/cloudelete.rb', line 33 def delete update_attributes deleted_at: DateTime.now end |
#delete_or_not ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/cloudelete.rb', line 24 def delete_or_not if @really_delete true else touch(:deleted_at) false end end |
#deleted? ⇒ Boolean
49 50 51 |
# File 'lib/cloudelete.rb', line 49 def deleted? !deleted_at.nil? end |
#destroy ⇒ Object
37 38 39 40 |
# File 'lib/cloudelete.rb', line 37 def destroy super self end |
#destroy! ⇒ Object
42 43 44 45 46 47 |
# File 'lib/cloudelete.rb', line 42 def destroy! @really_delete = true destroy @really_delete = false self end |
#restore ⇒ Object
53 54 55 56 |
# File 'lib/cloudelete.rb', line 53 def restore update_attributes deleted_at: nil self end |