Module: Textus::Domain::Policy::Predicates::Registry
- Defined in:
- lib/textus/domain/policy/predicates/registry.rb
Overview
The single source of truth for the predicate vocabulary (ADR 0031 §3). Replaces both Promote::KNOWN and Promotion::REGISTRY. Each entry is name => ->(params:, schemas:) { predicate }.
Constant Summary collapse
- ENTRIES =
{ "zone_writable_by" => ->(**) { ZoneWritableBy.new }, "author_held" => ->(**) { AuthorHeld.new }, "target_is_canon" => ->(**) { TargetIsCanon.new }, "schema_valid" => ->(schemas:, **) { SchemaValid.new(schemas: schemas) }, "etag_match" => ->(params:, **) { EtagMatch.new(if_etag: params) }, "fresh_within" => ->(params:, **) { FreshWithin.new(duration: params) }, }.freeze
Class Method Summary collapse
-
.build(spec, schemas:) ⇒ Object
Accepts either “name” or { “name” => params }.
- .known ⇒ Object
Class Method Details
.build(spec, schemas:) ⇒ Object
Accepts either “name” or { “name” => params }.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/textus/domain/policy/predicates/registry.rb', line 21 def self.build(spec, schemas:) name, params = if spec.is_a?(Hash) spec.first else [spec.to_s, nil] end ctor = ENTRIES[name.to_s] or raise Textus::UsageError.new( "unknown guard predicate: '#{name}' (known: #{ENTRIES.keys.join(", ")})", ) ctor.call(params: params, schemas: schemas) end |
.known ⇒ Object
34 |
# File 'lib/textus/domain/policy/predicates/registry.rb', line 34 def self.known = ENTRIES.keys |