Class: Vanguard::Validator::Builder

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/vanguard/validator/builder.rb

Constant Summary

Constants included from DSL

DSL::REGISTRY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DSL

#method_missing, register

Constructor Details

#initialize(&block) ⇒ undefined

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.

Initialize object



20
21
22
23
24
25
# File 'lib/vanguard/validator/builder.rb', line 20

def initialize(&block)
  @rules = []
  if block_given?
    instance_exec(&block)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Vanguard::DSL

Instance Attribute Details

#rulesEnumerator<Rule> (readonly)

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 rules

Returns:

  • (Enumerator<Rule>)


12
13
14
# File 'lib/vanguard/validator/builder.rb', line 12

def rules
  @rules
end

Instance Method Details

#add(rule) ⇒ self

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.

Add rule

Parameters:

Returns:

  • (self)


35
36
37
38
# File 'lib/vanguard/validator/builder.rb', line 35

def add(rule)
  @rules << rule
  self
end

#validatorValidator

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 validator

Returns:



46
47
48
# File 'lib/vanguard/validator/builder.rb', line 46

def validator
  Validator.new(rules)
end