Class: Clickwrap::LegalHold

Inherits:
ApplicationRecord show all
Defined in:
lib/clickwrap/models/legal_hold.rb

Overview

A legal hold pauses scheduled disposition for an event, an actor, or a policy.

It requires a reason, an owner, and a review date. That is not bureaucracy: an indefinite hold with no owner is exactly how "we'll delete it later" becomes "we kept everything forever", and a retention policy that can be suspended invisibly is not a retention policy. Placement and release append linked lifecycle events; this row is the current operational projection and changes only through the named release! transition.

Constant Summary collapse

SCOPES =
%w[event actor policy].freeze

Instance Method Summary collapse

Instance Method Details

#in_effect?Boolean

Returns:

  • (Boolean)


34
# File 'lib/clickwrap/models/legal_hold.rb', line 34

def in_effect? = !released?

#release!(because:, released_by:) ⇒ Object

Raises:



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/clickwrap/models/legal_hold.rb', line 36

def release!(because:, released_by:)
  raise LegalHoldInEffect, "Releasing a legal hold needs a `because:` explaining why." if because.to_s.strip.empty?
  raise LegalHoldInEffect, "Legal hold #{id} was already released at #{released_at}." if released?

  update_columns(
    released_at: Clickwrap.now,
    released_by_reference: Reference.actor(released_by),
    release_reason: because
  )
  self
end

#released?Boolean

Returns:

  • (Boolean)


33
# File 'lib/clickwrap/models/legal_hold.rb', line 33

def released? = released_at.present?

#to_sObject



48
# File 'lib/clickwrap/models/legal_hold.rb', line 48

def to_s = "legal hold on #{hold_scope} (#{reason})"