Class: AutomationObject::BluePrint::HashAdapter::Validators::ValidateModalPresenceOf
- Inherits:
-
Validate
- Object
- Validate
- AutomationObject::BluePrint::HashAdapter::Validators::ValidateModalPresenceOf
- Defined in:
- lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_modal_presence_of.rb
Overview
Validator that tests that a modal is defined when it is called elsewhere through a hook
Instance Attribute Summary
Attributes inherited from Validate
Instance Method Summary collapse
-
#initialize(args) ⇒ ValidateModalPresenceOf
constructor
A new instance of ValidateModalPresenceOf.
-
#validate(composite_object) ⇒ nil
Validates the composite object and throws errors on failure.
Methods inherited from Validate
Constructor Details
#initialize(args) ⇒ ValidateModalPresenceOf
Returns a new instance of ValidateModalPresenceOf
12 13 14 |
# File 'lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_modal_presence_of.rb', line 12 def initialize(args) @key = args.fetch :key end |
Instance Method Details
#validate(composite_object) ⇒ nil
Validates the composite object and throws errors on failure
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_modal_presence_of.rb', line 19 def validate(composite_object) # Get the hash value from the composite object target_value = composite_object.hash[@key] target_values = target_value.is_a?(Array) ? target_value : [target_value] return unless target_value valid_modals = find_modals(composite_object) populate_errors(target_values, valid_modals, composite_object) end |