Class: AutomationObject::BluePrint::HashAdapter::Validators::ValidateViewPresenceOf
- Inherits:
-
Validate
- Object
- Validate
- AutomationObject::BluePrint::HashAdapter::Validators::ValidateViewPresenceOf
- Defined in:
- lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_view_presence_of.rb
Overview
Validator that tests that a view is defined when it is called elsewhere through a hook
Instance Attribute Summary
Attributes inherited from Validate
Instance Method Summary collapse
-
#initialize(args) ⇒ ValidateViewPresenceOf
constructor
A new instance of ValidateViewPresenceOf.
-
#validate(composite_object) ⇒ nil
Validates the composite object and throws errors on failure.
Methods inherited from Validate
Constructor Details
#initialize(args) ⇒ ValidateViewPresenceOf
Returns a new instance of ValidateViewPresenceOf
12 13 14 |
# File 'lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_view_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_view_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_views = find_views(composite_object) populate_errors(target_values, valid_views, composite_object) end |