Class: Clickwrap::Retention::Planner::HoldIndex
- Inherits:
-
Object
- Object
- Clickwrap::Retention::Planner::HoldIndex
- Defined in:
- lib/clickwrap/retention/planner.rb
Overview
Every legal hold currently in effect, loaded once.
Holds are few and disposition runs touch many rows, so the alternative — three existence queries per candidate — would make the safety check the expensive part of the job, and an expensive safety check is one someone eventually turns off.
Class Method Summary collapse
Instance Method Summary collapse
- #held?(event) ⇒ Boolean
-
#initialize(event_ids:, actor_references:, policy_keys:) ⇒ HoldIndex
constructor
A new instance of HoldIndex.
Constructor Details
#initialize(event_ids:, actor_references:, policy_keys:) ⇒ HoldIndex
Returns a new instance of HoldIndex.
485 486 487 488 489 |
# File 'lib/clickwrap/retention/planner.rb', line 485 def initialize(event_ids:, actor_references:, policy_keys:) @event_ids = event_ids @actor_references = actor_references @policy_keys = policy_keys end |
Class Method Details
.load ⇒ Object
475 476 477 478 479 480 481 482 483 |
# File 'lib/clickwrap/retention/planner.rb', line 475 def self.load holds = LegalHold.in_effect.to_a new( event_ids: holds.select { |hold| hold.hold_scope == "event" }.map(&:event_id).compact.to_set, actor_references: holds.select { |hold| hold.hold_scope == "actor" }.map(&:actor_reference).compact.to_set, policy_keys: holds.select { |hold| hold.hold_scope == "policy" }.map(&:policy_key).compact.to_set ) end |
Instance Method Details
#held?(event) ⇒ Boolean
491 492 493 494 495 496 497 498 |
# File 'lib/clickwrap/retention/planner.rb', line 491 def held?(event) return false if event.nil? event.on_legal_hold? || @event_ids.include?(event.id) || @actor_references.include?(event.actor_reference) || @policy_keys.include?(event.policy_key) end |