Class: Textus::Domain::Policy::GuardFactory
- Inherits:
-
Object
- Object
- Textus::Domain::Policy::GuardFactory
- Defined in:
- lib/textus/domain/policy/guard_factory.rb
Overview
Builds the effective Guard for (transition, key): base floor ++ the predicates declared under rules[].guard. The single place the closed floor and the open ceiling are composed.
Instance Method Summary collapse
- #for(transition, key) ⇒ Object
-
#initialize(manifest:, schemas:, extra: {}) ⇒ GuardFactory
constructor
A new instance of GuardFactory.
Constructor Details
#initialize(manifest:, schemas:, extra: {}) ⇒ GuardFactory
Returns a new instance of GuardFactory.
10 11 12 13 14 |
# File 'lib/textus/domain/policy/guard_factory.rb', line 10 def initialize(manifest:, schemas:, extra: {}) @manifest = manifest @schemas = schemas @extra = extra # transient per-call params, e.g. { if_etag: "..." } end |
Instance Method Details
#for(transition, key) ⇒ Object
16 17 18 19 20 |
# File 'lib/textus/domain/policy/guard_factory.rb', line 16 def for(transition, key) specs = BaseGuards.for(transition) + composed(transition, key) predicates = specs.map { |spec| build(spec) }.uniq(&:name) Guard.new(predicates) end |