Class: Clickwrap::Services::LoadPolicies
- Inherits:
-
Object
- Object
- Clickwrap::Services::LoadPolicies
- Defined in:
- lib/clickwrap/services/load_policies.rb
Overview
Loads the host's document, policy, and retention declarations.
They live in ordinary Ruby files — config/clickwrap.rb and
config/clickwrap/*.rb by default — because that makes them reviewable in
a pull request and deployable like the code they are. The engine re-reads
them through to_prepare, so a development reload picks up an edit the
same way it picks up a model change.
Compilation happens here, at boot, and a mistake raises. A policy that references a document nobody declared, a consent statement with no withdrawal route, a one-time authorization with no expiry — each of those is a bug that would otherwise be discovered by the first person who tried to sign up, and each one gets a sentence explaining what to do about it.
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(paths: nil, root: nil) ⇒ LoadPolicies
constructor
A new instance of LoadPolicies.
- #resolve_files ⇒ Object
Constructor Details
#initialize(paths: nil, root: nil) ⇒ LoadPolicies
Returns a new instance of LoadPolicies.
19 20 21 22 |
# File 'lib/clickwrap/services/load_policies.rb', line 19 def initialize(paths: nil, root: nil) @paths = paths || Clickwrap.config.policy_paths @root = root || default_root end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
24 25 26 |
# File 'lib/clickwrap/services/load_policies.rb', line 24 def paths @paths end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
24 25 26 |
# File 'lib/clickwrap/services/load_policies.rb', line 24 def root @root end |
Instance Method Details
#call ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/clickwrap/services/load_policies.rb', line 26 def call files = resolve_files return [] if files.empty? reset_registries! files.each { |file| load_file(file) } ValidatePolicyReferences.call files end |