Class: Clickwrap::Services::ValidatePolicyReferences

Inherits:
Object
  • Object
show all
Defined in:
lib/clickwrap/services/validate_policy_references.rb

Overview

The policy DSL compiles each declaration immediately, while references may legitimately point at a declaration in a later file. This second pass runs after every file has loaded and resolves those names as one graph. A typo therefore fails boot, never the first production capture.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.callObject



12
# File 'lib/clickwrap/services/validate_policy_references.rb', line 12

def self.call = new.call

.validate_remediation_paths!Object

Routes are not knowable while Rails is still drawing them. The engine invokes this method from after_routes_loaded; non-Rails users still get syntax validation from Statement itself.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/clickwrap/services/validate_policy_references.rb', line 30

def self.validate_remediation_paths!
  return true unless defined?(::Rails) && ::Rails.respond_to?(:application)
  return true unless ::Rails.application

  Clickwrap.policies.each do |policy|
    policy.consent_statements.each do |statement|
      validate_remediation_path!(policy, statement)
    end
  end

  true
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/clickwrap/services/validate_policy_references.rb', line 14

def call
  Clickwrap.policies.each do |policy|
    validate_documents!(policy)
    retention_class = validate_retention_class!(policy)
    validate_request_evidence_retention!(policy, retention_class)
    validate_host_calculations!(policy, retention_class)
    validate_authority_adapter!(policy)
    validate_ip_geolocation_resolver!(policy)
  end

  true
end