module Sequel::Plugins::Paranoia::InstanceMethods

Public Instance Methods

delete() click to toggle source

Rather than delete the object, update its deleted timestamp field.

# File lib/sequel_paranoia.rb, line 62
def delete
  set_deleted_timestamp
end

Private Instance Methods

set_deleted_timestamp(time=nil) click to toggle source

If the object has accessor methods for the deleted timestamp field, and the deleted timestamp value is nil or overwriting it is allowed, set the deleted timestamp field to the time given or the current time.

# File lib/sequel_paranoia.rb, line 71
def set_deleted_timestamp(time=nil)
  field = model.deleted_timestamp_field
  meth = :"#{field}="
  if respond_to?(field) && respond_to?(meth) && (model.deleted_timestamp_overwrite? || send(field).nil?)
    self.send(meth, time||=Sequel.datetime_class.now)
    after_set_deleted_timestamp if respond_to? :after_set_deleted_timestamp
    self.save :validate => false
  end
end