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
24 25 26 27 |
# File 'lib/cloudelete.rb', line 24 def self.included(base) base.send :alias_method, :delete!, :delete base.send :before_destroy, :delete_or_not end |
Instance Method Details
#delete ⇒ Object
38 39 40 |
# File 'lib/cloudelete.rb', line 38 def delete update_attributes deleted_at: DateTime.now end |
#delete_or_not ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/cloudelete.rb', line 29 def delete_or_not if @really_delete true else touch(:deleted_at) false end end |
#deleted? ⇒ Boolean
54 55 56 |
# File 'lib/cloudelete.rb', line 54 def deleted? !deleted_at.nil? end |
#destroy ⇒ Object
42 43 44 45 |
# File 'lib/cloudelete.rb', line 42 def destroy super self end |
#destroy! ⇒ Object
47 48 49 50 51 52 |
# File 'lib/cloudelete.rb', line 47 def destroy! @really_delete = true destroy @really_delete = false self end |
#restore ⇒ Object
58 59 60 61 |
# File 'lib/cloudelete.rb', line 58 def restore update_attributes deleted_at: nil self end |