Module: Validate::AST::DefinitionContext::Builder
- Defined in:
- lib/validate/ast.rb
Class Method Summary collapse
- .all_constraints(*constraints) ⇒ Object
- .at_least_one_constraint(*constraints) ⇒ Object
- .constraint(name, args, block, trace) ⇒ Object
- .no_constraints(*constraints) ⇒ Object
- .value(value) ⇒ Object
Class Method Details
.all_constraints(*constraints) ⇒ Object
16 17 18 |
# File 'lib/validate/ast.rb', line 16 def all_constraints(*constraints) Rules::Unanimous.new(constraints.map { |node| send(*node) }) end |
.at_least_one_constraint(*constraints) ⇒ Object
20 21 22 |
# File 'lib/validate/ast.rb', line 20 def at_least_one_constraint(*constraints) Rules::Affirmative.new(constraints.map { |node| send(*node) }) end |
.constraint(name, args, block, trace) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/validate/ast.rb', line 28 def constraint(name, args, block, trace) if defined?(Constraints) && Constraints.respond_to?(name) begin return Constraints.send(name, *(args.map { |node| send(*node) }), &block) rescue => e ::Kernel.raise Error::ValidationRuleError, e., trace end end Rules::Pending.new(name, args.map { |node| send(*node) }, block, trace) end |
.no_constraints(*constraints) ⇒ Object
24 25 26 |
# File 'lib/validate/ast.rb', line 24 def no_constraints(*constraints) Rules::Negative.new(constraints.map { |node| send(*node) }) end |
.value(value) ⇒ Object
40 41 42 |
# File 'lib/validate/ast.rb', line 40 def value(value) value end |