module PermanentRecords

PermanentRecords works with ActiveRecord to set deleted_at columns with a timestamp reflecting when a record was 'deleted' instead of actually deleting the record. All dependent records and associations are treated exactly as you'd expect: If there's a deleted_at column then the record is preserved, otherwise it's deleted.

Public Class Methods

dependent_permanent_reflections(klass) click to toggle source
# File lib/permanent_records.rb, line 274
def self.dependent_permanent_reflections(klass)
  dependent_reflections(klass).select do |_name, reflection|
    reflection.klass.is_permanent?
  end
end
dependent_record_window() click to toggle source
# File lib/permanent_records.rb, line 259
def self.dependent_record_window
  @dependent_record_window || 3.seconds
end
dependent_record_window=(time_value) click to toggle source
# File lib/permanent_records.rb, line 263
def self.dependent_record_window=(time_value)
  @dependent_record_window = time_value
end
dependent_reflections(klass) click to toggle source
# File lib/permanent_records.rb, line 267
def self.dependent_reflections(klass)
  klass.reflections.select do |_, reflection|
    # skip if there are no dependent record instances
    reflection.options[:dependent] == :destroy
  end
end
should_force_destroy?(force) click to toggle source
# File lib/permanent_records.rb, line 243
def self.should_force_destroy?(force)
  if force.is_a?(Hash)
    force[:force]
  else
    force == :force
  end
end
should_ignore_validations?(force) click to toggle source
# File lib/permanent_records.rb, line 255
def self.should_ignore_validations?(force)
  force.is_a?(Hash) && force[:validate] == false
end
should_revive_parent_first?(order) click to toggle source
# File lib/permanent_records.rb, line 251
def self.should_revive_parent_first?(order)
  order.is_a?(Hash) && order[:reverse] == true
end