class Dry::Schema::Predicate
@api public
Predicate objects used within the DSL
def !
- Api: - public
Returns:
-
(Negation)
-
def ! Negation.new(self) end
def ensure_valid
- Api: - private
def ensure_valid if arity - 1 != args.size raise ArgumentError, "#{name} predicate arity is invalid" end end
def initialize(compiler, name, args, block)
- Api: - private
def initialize(compiler, name, args, block) @compiler = compiler @name = name @args = args @block = block # Cater for optional second argument like in case of `eql?` or `respond_to?` @arity = compiler.predicates[name].arity.abs end
def to_ast(*)
- Api: - private
Returns:
-
(Array)
-
def to_ast(*) [:predicate, [name, compiler.predicates.arg_list(name, *args)]] end
def to_rule
- Api: - private
def to_rule compiler.visit(to_ast) end