module Resurrection::Model
Public Instance Methods
after_delete()
click to toggle source
# File lib/resurrection/model.rb, line 41 def after_delete return end
after_resurrection()
click to toggle source
# File lib/resurrection/model.rb, line 49 def after_resurrection return end
before_delete()
click to toggle source
# File lib/resurrection/model.rb, line 45 def before_delete return end
delete()
click to toggle source
# File lib/resurrection/model.rb, line 19 def delete # if the record is new or destroyed, do nothing return if new_record? or deleted? # Calls before_delete callbacks before deletion takes place run_callbacks :deleted do update_attribute_or_column :deleted_at, Time.now end end
Also aliased as: delete!
deleted?()
click to toggle source
# File lib/resurrection/model.rb, line 37 def deleted? !self.deleted_at.nil? end
resurrect()
click to toggle source
# File lib/resurrection/model.rb, line 30 def resurrect run_callbacks :resurrected do update_attribute_or_column :deleted_at, nil end end
Also aliased as: resurrect!
Private Instance Methods
update_attribute_or_column(*args)
click to toggle source
Rails 3.1 adds update_column. Rails > 3.2.6 deprecates update_attribute, gone in Rails 4.
# File lib/resurrection/model.rb, line 56 def update_attribute_or_column(*args) respond_to?(:update_attribute) ? update_attribute(*args) : update_column(*args) end