Module: Attestor::Validations::ClassMethods
- Included in:
- Policy, Attestor::Validations
- Defined in:
- lib/attestor/validations.rb
Instance Method Summary collapse
-
#validate(name = nil, except: nil, only: nil, &block) ⇒ Attestor::Validators
Uses an instance method or block for validation.
-
#validates(name = nil, except: nil, only: nil, &block) ⇒ Attestor::Validators
Delegates a validation to instance method or block.
-
#validations(*options, &block) ⇒ undefined
Groups validations assigned to shared context.
-
#validators ⇒ Attestor::Validators
private
Returns a collection of applied validators.
Instance Method Details
#validate(name, except: nil, only: nil) ⇒ Attestor::Validators #validate(except: nil, only: nil, &block) ⇒ Attestor::Validators
Uses an instance method or block for validation
Mutates the class by changing its #validators attribute!
86 87 88 |
# File 'lib/attestor/validations.rb', line 86 def validate(*args, &block) @validators = validators.add_validator(*args, &block) end |
#validates(name, except: nil, only: nil) ⇒ Attestor::Validators #validates(except: nil, only: nil, &block) ⇒ Attestor::Validators
Delegates a validation to instance method or block
Mutates the class by changing its #validators attribute!
110 111 112 |
# File 'lib/attestor/validations.rb', line 110 def validates(*args, &block) @validators = validators.add_delegator(*args, &block) end |
#validations(*options, &block) ⇒ undefined
Groups validations assigned to shared context
131 132 133 |
# File 'lib/attestor/validations.rb', line 131 def validations(*, &block) Context.new(self, Hash[*]).instance_eval(&block) if block_given? end |
#validators ⇒ Attestor::Validators
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.
Returns a collection of applied validators
61 62 63 |
# File 'lib/attestor/validations.rb', line 61 def validators @validators ||= Validators.new end |