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

Instance Method Details

- (Array) all_validations

An array of instances of all validations for this object

Returns:

  • (Array)


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

Returns:

  • (Array)


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?

Returns:

  • (true, false)


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

Returns:

  • (Array)


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?

Returns:

  • (true, false)


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