Class: Liminal::PredicateRegistry
- Inherits:
-
Object
- Object
- Liminal::PredicateRegistry
- Defined in:
- lib/liminal/predicate_registry.rb
Overview
Immutable registry of declarative dry predicate handlers.
Defined Under Namespace
Classes: Entry, UnsupportedValue
Class Method Summary collapse
-
.default ⇒ PredicateRegistry
Return the immutable registry containing all built-in predicates.
Instance Method Summary collapse
-
#entry(name) ⇒ Entry?
Look up a predicate entry.
-
#initialize(entries = {}) ⇒ PredicateRegistry
constructor
A new instance of PredicateRegistry.
-
#with(name, replace: false) {|arguments, context| ... } ⇒ PredicateRegistry
Return a new registry containing
namewithout mutating this registry.
Constructor Details
#initialize(entries = {}) ⇒ PredicateRegistry
Returns a new instance of PredicateRegistry.
190 191 192 193 |
# File 'lib/liminal/predicate_registry.rb', line 190 def initialize(entries = {}) @entries = entries.freeze freeze end |
Class Method Details
.default ⇒ PredicateRegistry
Return the immutable registry containing all built-in predicates.
26 27 28 |
# File 'lib/liminal/predicate_registry.rb', line 26 def default @default ||= build_default.freeze end |
Instance Method Details
#entry(name) ⇒ Entry?
Look up a predicate entry. Intended for compiler adapters.
213 214 215 |
# File 'lib/liminal/predicate_registry.rb', line 213 def entry(name) @entries[name.to_sym] end |
#with(name, replace: false) {|arguments, context| ... } ⇒ PredicateRegistry
Return a new registry containing name without mutating this registry.
203 204 205 206 207 |
# File 'lib/liminal/predicate_registry.rb', line 203 def with(name, replace: false, &handler) raise ArgumentError, "a predicate handler block is required" unless handler add(name, handler, replace: replace, internal: false) end |