Class: Dry::Validation::Schema::Check

Inherits:
Value
  • Object
show all
Defined in:
lib/dry/validation/schema/check.rb

Instance Attribute Summary

Attributes inherited from Value

#schema_class, #type

Attributes inherited from DSL

#checks, #name, #options, #parent, #rules

Instance Method Summary collapse

Methods inherited from Value

#check, #configure, #confirmation, #each, #initialize, #root?, #rule, #schema, #value, #when

Methods inherited from DSL

[], #add_check, #add_rule, #attr, #initialize, #key, #not, #optional, #path, #rule_ast, #to_ast, #to_rule, #with

Constructor Details

This class inherits a constructor from Dry::Validation::Schema::Value

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *meth_args) ⇒ Object (private)



11
12
13
14
15
16
17
18
19
20
# File 'lib/dry/validation/schema/check.rb', line 11

def method_missing(meth, *meth_args)
  vals, args = meth_args.partition { |arg| arg.class < DSL }

  keys = [name, *vals.map(&:name)]
  predicate = [:predicate, [meth, args]]

  rule = create_rule([:check, [name, predicate, keys]])
  add_rule(rule)
  rule
end

Instance Method Details

#classObject



5
6
7
# File 'lib/dry/validation/schema/check.rb', line 5

def class
  Check
end