Class: Clickwrap::RetentionClass
- Inherits:
-
Object
- Object
- Clickwrap::RetentionClass
- Defined in:
- lib/clickwrap/retention_class.rb
Overview
An application-defined retention class: how long each part of an event is kept, and what triggers the clock.
Clickwrap.retention :ordinary_agreement_evidence do
retain_core_event_indefinitely
delete_recorded_ip_address_after 6.years
delete_recorded_browser_user_agent_after 6.years
end
The default — for any part not given a rule, the core event included — is to keep the evidence indefinitely. That direction is deliberate: keeping is reversible (a reviewed disposition can always run later) while deletion is not, and the day contractual evidence matters is usually years away. Deletion is therefore the explicit, reviewed act, never a default.
Clickwrap does not choose deletion periods and cannot tell you whether yours are right. What it does is make a reviewed decision executable and auditable, keep the core event's schedule separate from the optional personal request evidence, and delegate event-based or "later of" rules to a named host calculation. The host owns that calculation because a fixed duration cannot express "five years, or three years after this contract is liquidated, whichever is later" without application domain state.
Defined Under Namespace
Classes: Rule
Constant Summary collapse
- PARTS =
%i[core_event ip_address browser_user_agent ip_geolocation].freeze
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
-
#initialize(key:, rules:) ⇒ RetentionClass
constructor
A new instance of RetentionClass.
- #rule_for(part) ⇒ Object
- #to_snapshot ⇒ Object
Constructor Details
#initialize(key:, rules:) ⇒ RetentionClass
Returns a new instance of RetentionClass.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/clickwrap/retention_class.rb', line 52 def initialize(key:, rules:) @key = key.to_s # A part with no declared rule is kept indefinitely. For the core event # that default is made explicit here, so every consumer — the planner, # the privacy inventory, the snapshot on a plan — sees a reviewed answer # ("indefinite") rather than a silence it must interpret. rules = rules.dup rules[:core_event] ||= Rule.new(part: :core_event, indefinite: true) @rules = rules.freeze validate! freeze end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
50 51 52 |
# File 'lib/clickwrap/retention_class.rb', line 50 def key @key end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
50 51 52 |
# File 'lib/clickwrap/retention_class.rb', line 50 def rules @rules end |
Instance Method Details
#rule_for(part) ⇒ Object
66 |
# File 'lib/clickwrap/retention_class.rb', line 66 def rule_for(part) = rules[part.to_sym] |
#to_snapshot ⇒ Object
68 69 70 71 72 73 |
# File 'lib/clickwrap/retention_class.rb', line 68 def to_snapshot { "key" => key, "rules" => rules.to_h { |part, rule| [part.to_s, rule.to_snapshot] } } end |