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_for 6.years
delete_recorded_ip_address_after 90.days
delete_recorded_browser_user_agent_after 90.days
delete_recorded_ip_geolocation_after 90.days
end
Clickwrap does not choose these 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.
42 43 44 45 46 47 48 |
# File 'lib/clickwrap/retention_class.rb', line 42 def initialize(key:, rules:) @key = key.to_s @rules = rules.freeze validate! freeze end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
40 41 42 |
# File 'lib/clickwrap/retention_class.rb', line 40 def key @key end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
40 41 42 |
# File 'lib/clickwrap/retention_class.rb', line 40 def rules @rules end |
Instance Method Details
#rule_for(part) ⇒ Object
50 |
# File 'lib/clickwrap/retention_class.rb', line 50 def rule_for(part) = rules[part.to_sym] |
#to_snapshot ⇒ Object
52 53 54 55 56 57 |
# File 'lib/clickwrap/retention_class.rb', line 52 def to_snapshot { "key" => key, "rules" => rules.to_h { |part, rule| [part.to_s, rule.to_snapshot] } } end |