Class: DynamicValidation::BlockValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- DynamicValidation::BlockValidator
- Defined in:
- lib/dynamic_validation.rb
Overview
BlockValidator is a wrapper validator allow for blocks / lambda to be passed at dynamically at runtime instead of having to pass in an object. This will allow for quick and dirty validations, that don't need to be pulled into their own objects just yet.
Instance Method Summary collapse
-
#initialize(options) ⇒ BlockValidator
constructor
A new instance of BlockValidator.
- #validate(record) ⇒ Object
Constructor Details
#initialize(options) ⇒ BlockValidator
Returns a new instance of BlockValidator
92 93 94 |
# File 'lib/dynamic_validation.rb', line 92 def initialize() @block = .fetch(:block) end |
Instance Method Details
#validate(record) ⇒ Object
96 97 98 |
# File 'lib/dynamic_validation.rb', line 96 def validate(record) @block.call(record) end |