Class: Dry::Schema::PredicateRegistry Private
- Inherits:
-
Object
- Object
- Dry::Schema::PredicateRegistry
- Defined in:
- lib/dry/schema/predicate_registry.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A registry with predicate objects from ‘Dry::Logic::Predicates`
Instance Attribute Summary collapse
- #has_predicate ⇒ Object readonly private
- #predicates ⇒ Object readonly private
Instance Method Summary collapse
- #[](name) ⇒ Object private
- #arg_list(name, *values) ⇒ Object private
-
#initialize(predicates = Dry::Logic::Predicates) ⇒ PredicateRegistry
constructor
private
A new instance of PredicateRegistry.
- #key?(name) ⇒ Boolean private
Constructor Details
#initialize(predicates = Dry::Logic::Predicates) ⇒ PredicateRegistry
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of PredicateRegistry.
18 19 20 21 |
# File 'lib/dry/schema/predicate_registry.rb', line 18 def initialize(predicates = Dry::Logic::Predicates) @predicates = predicates @has_predicate = ::Kernel.instance_method(:respond_to?).bind(@predicates) end |
Instance Attribute Details
#has_predicate ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/dry/schema/predicate_registry.rb', line 15 def has_predicate @has_predicate end |
#predicates ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/dry/schema/predicate_registry.rb', line 12 def predicates @predicates end |
Instance Method Details
#[](name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/dry/schema/predicate_registry.rb', line 24 def [](name) predicates[name] end |
#arg_list(name, *values) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 38 39 40 41 |
# File 'lib/dry/schema/predicate_registry.rb', line 34 def arg_list(name, *values) predicate = self[name] predicate .parameters .map(&:last) .zip(values + Array.new(predicate.arity - values.size, Undefined)) end |
#key?(name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'lib/dry/schema/predicate_registry.rb', line 29 def key?(name) has_predicate.(name) end |