module Sequel::Plugins::SoftDeletes

Plugin for adding soft-delete to a model.

Example

Defining a model class with a timestamp as the deletion flag:

class ACME::Customer < Sequel::Model(:customers)
    plugin :soft_deletes, column: :deleted_at

And in the schema:

create_table( :customers ) do
    primary_key :id
    timestamptz :deleted_at
end

Constants

DEFAULT_OPTIONS

Default plugin options

VERSION

Public Class Methods

configure(model, opts=DEFAULT_OPTIONS) click to toggle source
# File lib/sequel/plugins/soft_deletes.rb, line 30
def self.configure(model, opts=DEFAULT_OPTIONS)
  opts = DEFAULT_OPTIONS.merge(opts)
  column = opts[:column]
  model.soft_delete_column = column
  model.set_dataset(model.where(column => nil)) if opts[:omit_by_default]
end