Class: Textus::Manifest::Policies
- Inherits:
-
Object
- Object
- Textus::Manifest::Policies
- Defined in:
- lib/textus/manifest/policies.rb
Defined Under Namespace
Constant Summary collapse
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
Class Method Summary collapse
Instance Method Summary collapse
- #explain(key) ⇒ Object
- #for(key) ⇒ Object
-
#initialize(blocks) ⇒ Policies
constructor
A new instance of Policies.
Constructor Details
#initialize(blocks) ⇒ Policies
Returns a new instance of Policies.
11 12 13 |
# File 'lib/textus/manifest/policies.rb', line 11 def initialize(blocks) @blocks = blocks end |
Instance Attribute Details
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
15 16 17 |
# File 'lib/textus/manifest/policies.rb', line 15 def blocks @blocks end |
Class Method Details
Instance Method Details
#explain(key) ⇒ Object
32 33 34 |
# File 'lib/textus/manifest/policies.rb', line 32 def explain(key) @blocks.select { |b| Textus::Domain::Policy::Matcher.matches?(b.match, key) } end |
#for(key) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/textus/manifest/policies.rb', line 17 def for(key) slots = { refresh: [], handler_allowlist: [], promote: [], retention: [] } @blocks.each do |b| next unless Textus::Domain::Policy::Matcher.matches?(b.match, key) slots.each_key { |slot| slots[slot] << b if b.public_send(slot) } end PolicySet.new( refresh: pick(slots[:refresh], :refresh, key), handler_allowlist: pick(slots[:handler_allowlist], :handler_allowlist, key), promote: pick(slots[:promote], :promote, key), retention: pick(slots[:retention], :retention, key), ) end |