Module: ActsAsArchived::Base

Defined in:
app/models/concerns/acts_as_archived.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_archived(cascade: [], strategy: :archive) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/concerns/acts_as_archived.rb', line 32

def acts_as_archived(cascade: [], strategy: :archive)

  cascade = Array(cascade).compact
  strategy = strategy

  if cascade.any? { |obj| !obj.kind_of?(Symbol) }
    raise 'expected cascade to be an Array of has_many symbols'
  end

  unless [:archive, :archive_all, :active_job].include?(strategy)
    raise 'expected strategy to be :archive, :archive_all, or :active_job'
  end

  @acts_as_archived_options = { cascade: cascade, strategy: strategy }

  include ::ActsAsArchived
end