Module: AutomationObject::BluePrint::HashAdapter::ValidationHelper
- Included in:
- Composite
- Defined in:
- lib/automation_object/blue_print/hash_adapter/helpers/validation_helper.rb
Overview
Validation helper for the composite structure, will allow Rails style validations on the composite
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#errors ⇒ Array<String>
Give errors a default empty Array.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_errors(errors) ⇒ Array<String>
Give errors a default empty Array.
-
#valid? ⇒ Boolean
Composite valid?.
Instance Attribute Details
#errors ⇒ Array<String>
Give errors a default empty Array
25 26 27 |
# File 'lib/automation_object/blue_print/hash_adapter/helpers/validation_helper.rb', line 25 def errors @errors end |
Class Method Details
.included(base) ⇒ Object
54 55 56 |
# File 'lib/automation_object/blue_print/hash_adapter/helpers/validation_helper.rb', line 54 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#add_errors(errors) ⇒ Array<String>
Give errors a default empty Array
32 33 34 |
# File 'lib/automation_object/blue_print/hash_adapter/helpers/validation_helper.rb', line 32 def add_errors(errors) self.errors += errors end |
#valid? ⇒ Boolean
Returns composite valid?
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/automation_object/blue_print/hash_adapter/helpers/validation_helper.rb', line 37 def valid? return true if self.class.skip_validations # ap self.class # ap self.class.name self.class.validations.collect do |validation| # ap validation.class.name end self.class.validations.collect do |validation| validation.validate(self) add_errors(validation.) unless validation.valid? end self.errors.empty? end |