class Dry::Schema::Predicate

@api public
Predicate objects used within the DSL

def !

Other tags:
    Api: - public

Returns:
  • (Negation) -
def !
  Negation.new(self)
end

def ensure_valid

Other tags:
    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)

Other tags:
    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(*)

Other tags:
    Api: - private

Returns:
  • (Array) -
def to_ast(*)
  [:predicate, [name, compiler.predicates.arg_list(name, *args)]]
end

def to_rule

Other tags:
    Api: - private
def to_rule
  compiler.visit(to_ast)
end