Class: WeakParameters::Validator
- Inherits:
-
Object
- Object
- WeakParameters::Validator
- Defined in:
- lib/weak_parameters/validator.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(params, &block) ⇒ Validator
constructor
A new instance of Validator.
- #validate ⇒ Object
- #validators ⇒ Object
Constructor Details
#initialize(params, &block) ⇒ Validator
Returns a new instance of Validator.
5 6 7 8 |
# File 'lib/weak_parameters/validator.rb', line 5 def initialize(params, &block) @params = params instance_eval(&block) end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/weak_parameters/validator.rb', line 3 def block @block end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/weak_parameters/validator.rb', line 3 def params @params end |
Instance Method Details
#validate ⇒ Object
10 11 12 |
# File 'lib/weak_parameters/validator.rb', line 10 def validate validators.each(&:validate) end |
#validators ⇒ Object
14 15 16 |
# File 'lib/weak_parameters/validator.rb', line 14 def validators @validators ||= [] end |