Class: Dry::Schema::Compiler Private

Inherits:
Logic::RuleCompiler
  • Object
show all
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

Instance Method Summary collapse

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

Returns:



14
15
16
# File 'lib/dry/schema/compiler.rb', line 14

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

Parameters:

  • predicate (Symbol)

Returns:

  • (Boolean)


46
47
48
# File 'lib/dry/schema/compiler.rb', line 46

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.



19
20
21
# File 'lib/dry/schema/compiler.rb', line 19

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

Parameters:

  • node (Array)
  • _opts (Hash) (defaults to: EMPTY_HASH)

    Unused

Returns:



34
35
36
37
# File 'lib/dry/schema/compiler.rb', line 34

def visit_namespace(node, _opts = EMPTY_HASH)
  namespace, rest = node
  NamespacedRule.new(namespace, visit(rest))
end