Module: WhyValidationsSuckIn96::ValidationSupport::InstanceMethods
- Defined in:
- lib/whyvalidationssuckin96/validation_support.rb
Overview
Instance methods added to any class or module that mixes in ValidationSupport
Instance Method Summary
- - (Array) all_validations An array of instances of all validations for this object.
- - (Array) failed_validations An array of instances of failed validations.
- - (true, false) invalid? Is this object invalid?.
- - (Array) passed_validations An array of instances of passed validations.
- - (true, false) valid? Is this object valid?.
Instance Method Details
- (Array) all_validations
An array of instances of all validations for this object
44 45 46 47 48 |
# File 'lib/whyvalidationssuckin96/validation_support.rb', line 44 def all_validations @all_validations ||= self.class.validation_collection.collect do |(vc,opts)| vc.new(self, opts) end end |
- (Array) failed_validations
An array of instances of failed validations
32 33 34 |
# File 'lib/whyvalidationssuckin96/validation_support.rb', line 32 def failed_validations all_validations.select { |validation| validation.failed? } end |
- (true, false) invalid?
Is this object invalid?
18 19 20 |
# File 'lib/whyvalidationssuckin96/validation_support.rb', line 18 def invalid? !valid? end |
- (Array) passed_validations
An array of instances of passed validations
38 39 40 |
# File 'lib/whyvalidationssuckin96/validation_support.rb', line 38 def passed_validations all_validations.select { |validation| validation.passed? } end |
- (true, false) valid?
Is this object valid?
24 25 26 27 28 |
# File 'lib/whyvalidationssuckin96/validation_support.rb', line 24 def valid? all_validations.collect do |validation| validation.validates? end.all? end |