Class: Clickwrap::DSL::RetentionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/clickwrap/dsl/retention_builder.rb

Overview

The block passed to Clickwrap.retention.

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

Two vocabularies on purpose. retain_..._for and retain_..._until say how long evidence is kept; delete_..._after says when personal request evidence goes away. They read differently because they are different intentions, and the second one is the destructive one.

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ RetentionBuilder

Returns a new instance of RetentionBuilder.



19
20
21
22
# File 'lib/clickwrap/dsl/retention_builder.rb', line 19

def initialize(key)
  @key = key.to_s
  @rules = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *_arguments, **_options) ⇒ Object (private)

Raises:



80
81
82
83
84
# File 'lib/clickwrap/dsl/retention_builder.rb', line 80

def method_missing(name, *_arguments, **_options)
  raise DefinitionError,
        "Retention class #{@key} calls unknown DSL method `#{name}`. Check the spelling; " \
        "Clickwrap never ignores retention declarations."
end

Instance Method Details

#compileObject



65
# File 'lib/clickwrap/dsl/retention_builder.rb', line 65

def compile = RetentionClass.new(key: @key, rules: @rules)

#delete_recorded_browser_user_agent_after(duration) ⇒ Object



45
46
47
# File 'lib/clickwrap/dsl/retention_builder.rb', line 45

def delete_recorded_browser_user_agent_after(duration)
  assign_rule!(:browser_user_agent, duration:)
end

#delete_recorded_ip_address_after(duration) ⇒ Object

--- Optional request evidence -------------------------------------------



41
42
43
# File 'lib/clickwrap/dsl/retention_builder.rb', line 41

def delete_recorded_ip_address_after(duration)
  assign_rule!(:ip_address, duration:)
end

#delete_recorded_ip_geolocation_after(duration) ⇒ Object



49
50
51
# File 'lib/clickwrap/dsl/retention_builder.rb', line 49

def delete_recorded_ip_geolocation_after(duration)
  assign_rule!(:ip_geolocation, duration:)
end

#retain_core_event_for(duration) ⇒ Object

--- The core event -------------------------------------------------------



26
27
28
# File 'lib/clickwrap/dsl/retention_builder.rb', line 26

def retain_core_event_for(duration)
  assign_rule!(:core_event, duration:)
end

#retain_core_event_until(host_event_name) ⇒ Object

For obligations a duration cannot express — "five years, or three years after this contract is liquidated, whichever is later". The named calculation is registered by the host on the configuration object, and it may legitimately return nil while the triggering event has not happened, in which case the record is simply not due yet.



35
36
37
# File 'lib/clickwrap/dsl/retention_builder.rb', line 35

def retain_core_event_until(host_event_name)
  assign_rule!(:core_event, host_event_name:)
end

#retain_recorded_browser_user_agent_until(host_event_name) ⇒ Object



57
58
59
# File 'lib/clickwrap/dsl/retention_builder.rb', line 57

def retain_recorded_browser_user_agent_until(host_event_name)
  assign_rule!(:browser_user_agent, host_event_name:)
end

#retain_recorded_ip_address_until(host_event_name) ⇒ Object



53
54
55
# File 'lib/clickwrap/dsl/retention_builder.rb', line 53

def retain_recorded_ip_address_until(host_event_name)
  assign_rule!(:ip_address, host_event_name:)
end

#retain_recorded_ip_geolocation_until(host_event_name) ⇒ Object



61
62
63
# File 'lib/clickwrap/dsl/retention_builder.rb', line 61

def retain_recorded_ip_geolocation_until(host_event_name)
  assign_rule!(:ip_geolocation, host_event_name:)
end