module Softie::ClassMethods

Public Instance Methods

softie(options = {}) click to toggle source
# File lib/softie.rb, line 7
def softie(options = {})
  class_attribute :softie_options

  self.softie_options = {
    key: :deleted_at,
    scope: :active,
    deleted_by_class: nil,
    deleted_by_key: :deleted_by
  }.merge(options)

  key softie_options[:key], Time

  if softie_options[:deleted_by_class]
    key softie_options[:deleted_by_key],
        softie_options[:deleted_by_class]
  end

  scope softie_options[:scope], lambda {
    where(softie_options[:key] => nil)
  } if softie_options[:scope]
end