Class: Clickwrap::Retention::Planner::Item

Inherits:
Data
  • Object
show all
Defined in:
lib/clickwrap/retention/planner.rb

Overview

One line of a plan. eligibility records which question the applier must re-ask: a retention plan re-checks whether the rule still says the item is due, while an actor-request plan re-checks that the item still exists and is not held, because whether an erasure request outranks a retention duty is a decision a human made, not one this gem can make.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(part:, status:, event_id: nil, record_id: nil, policy_key: nil, actor_reference: nil, retention_class_key: nil, eligible_at: nil, rule: nil, detail: nil, eligibility: "retention") ⇒ Item

Returns a new instance of Item.



67
68
69
70
71
# File 'lib/clickwrap/retention/planner.rb', line 67

def initialize(part:, status:, event_id: nil, record_id: nil, policy_key: nil,
               actor_reference: nil, retention_class_key: nil, eligible_at: nil,
               rule: nil, detail: nil, eligibility: "retention")
  super
end

Instance Attribute Details

#actor_referenceObject (readonly)

Returns the value of attribute actor_reference

Returns:

  • (Object)

    the current value of actor_reference



65
66
67
# File 'lib/clickwrap/retention/planner.rb', line 65

def actor_reference
  @actor_reference
end

#detailObject (readonly)

Returns the value of attribute detail

Returns:

  • (Object)

    the current value of detail



65
66
67
# File 'lib/clickwrap/retention/planner.rb', line 65

def detail
  @detail
end

#eligibilityObject (readonly)

Returns the value of attribute eligibility

Returns:

  • (Object)

    the current value of eligibility



65
66
67
# File 'lib/clickwrap/retention/planner.rb', line 65

def eligibility
  @eligibility
end

#eligible_atObject (readonly)

Returns the value of attribute eligible_at

Returns:

  • (Object)

    the current value of eligible_at



65
66
67
# File 'lib/clickwrap/retention/planner.rb', line 65

def eligible_at
  @eligible_at
end

#event_idObject (readonly)

Returns the value of attribute event_id

Returns:

  • (Object)

    the current value of event_id



65
66
67
# File 'lib/clickwrap/retention/planner.rb', line 65

def event_id
  @event_id
end

#partObject (readonly)

Returns the value of attribute part

Returns:

  • (Object)

    the current value of part



65
66
67
# File 'lib/clickwrap/retention/planner.rb', line 65

def part
  @part
end

#policy_keyObject (readonly)

Returns the value of attribute policy_key

Returns:

  • (Object)

    the current value of policy_key



65
66
67
# File 'lib/clickwrap/retention/planner.rb', line 65

def policy_key
  @policy_key
end

#record_idObject (readonly)

Returns the value of attribute record_id

Returns:

  • (Object)

    the current value of record_id



65
66
67
# File 'lib/clickwrap/retention/planner.rb', line 65

def record_id
  @record_id
end

#retention_class_keyObject (readonly)

Returns the value of attribute retention_class_key

Returns:

  • (Object)

    the current value of retention_class_key



65
66
67
# File 'lib/clickwrap/retention/planner.rb', line 65

def retention_class_key
  @retention_class_key
end

#ruleObject (readonly)

Returns the value of attribute rule

Returns:

  • (Object)

    the current value of rule



65
66
67
# File 'lib/clickwrap/retention/planner.rb', line 65

def rule
  @rule
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



65
66
67
# File 'lib/clickwrap/retention/planner.rb', line 65

def status
  @status
end

Class Method Details

.from_plan_entry(entry) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/clickwrap/retention/planner.rb', line 89

def self.from_plan_entry(entry)
  entry = entry.to_h
  new(
    part: entry["part"].to_s.to_sym,
    status: entry["status"].to_s.to_sym,
    event_id: entry["event_id"],
    record_id: entry["record_id"],
    policy_key: entry["policy_key"],
    actor_reference: entry["actor_reference"],
    retention_class_key: entry["retention_class"],
    rule: entry["rule"],
    detail: entry["detail"],
    eligibility: entry["eligibility"] || "retention"
  )
end

Instance Method Details

#to_plan_entryObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/clickwrap/retention/planner.rb', line 73

def to_plan_entry
  {
    "part" => part.to_s,
    "status" => status.to_s,
    "event_id" => event_id,
    "record_id" => record_id&.to_s,
    "policy_key" => policy_key,
    "actor_reference" => actor_reference,
    "retention_class" => retention_class_key,
    "eligible_at" => eligible_at && Receipt.format_time(eligible_at),
    "rule" => rule,
    "detail" => detail,
    "eligibility" => eligibility
  }.compact
end