Class: Veto::CustomMethodValidator
- Inherits:
-
AbstractValidator
- Object
- AbstractValidator
- Veto::CustomMethodValidator
- Defined in:
- lib/veto/validators/custom_method_validator.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
Instance Method Summary collapse
- #execute(context, entity, errors) ⇒ Object
-
#initialize(method_name, conditions) ⇒ CustomMethodValidator
constructor
A new instance of CustomMethodValidator.
Constructor Details
#initialize(method_name, conditions) ⇒ CustomMethodValidator
Returns a new instance of CustomMethodValidator.
8 9 10 11 |
# File 'lib/veto/validators/custom_method_validator.rb', line 8 def initialize method_name, conditions @method_name = method_name @conditions = conditions end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
6 7 8 |
# File 'lib/veto/validators/custom_method_validator.rb', line 6 def conditions @conditions end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
6 7 8 |
# File 'lib/veto/validators/custom_method_validator.rb', line 6 def method_name @method_name end |
Instance Method Details
#execute(context, entity, errors) ⇒ Object
13 14 15 16 17 |
# File 'lib/veto/validators/custom_method_validator.rb', line 13 def execute context, entity, errors if truthy_conditions?(@conditions, context, entity) context.send(method_name) end end |