Class: Dry::Schema::Compiler Private
- Inherits:
-
Logic::RuleCompiler
- Object
- Logic::RuleCompiler
- Dry::Schema::Compiler
- Includes:
- Extensions::Hints::CompilerMethods
- Defined in:
- lib/dry/schema/compiler.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.
Extended rule compiler used internally by the DSL
Class Method Summary collapse
-
.new(predicates = PredicateRegistry.new) ⇒ Compiler
private
Builds a default compiler instance with custom predicate registry.
Instance Method Summary collapse
-
#support?(predicate) ⇒ Boolean
private
Return true if a given predicate is supported by this compiler.
- #visit_and(node) ⇒ Object private
-
#visit_namespace(node, _opts = EMPTY_HASH) ⇒ NamespacedRule
private
Build a special rule that will produce namespaced failures.
Class Method Details
.new(predicates = PredicateRegistry.new) ⇒ Compiler
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.
Builds a default compiler instance with custom predicate registry
17 18 19 |
# File 'lib/dry/schema/compiler.rb', line 17 def self.new(predicates = PredicateRegistry.new) super end |
Instance Method Details
#support?(predicate) ⇒ 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.
Return true if a given predicate is supported by this compiler
49 50 51 |
# File 'lib/dry/schema/compiler.rb', line 49 def support?(predicate) predicates.key?(predicate) end |
#visit_and(node) ⇒ 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.
22 23 24 |
# File 'lib/dry/schema/compiler.rb', line 22 def visit_and(node) super.with(hints: false) end |
#visit_namespace(node, _opts = EMPTY_HASH) ⇒ NamespacedRule
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.
Build a special rule that will produce namespaced failures
This is needed for schemas that are namespaced and they are used as nested schemas
37 38 39 40 |
# File 'lib/dry/schema/compiler.rb', line 37 def visit_namespace(node, _opts = EMPTY_HASH) namespace, rest = node NamespacedRule.new(namespace, visit(rest)) end |