lib/whyvalidationssuckin96/validation_support.rb in whyvalidationssuckin96-1.2.3 vs lib/whyvalidationssuckin96/validation_support.rb in whyvalidationssuckin96-1.3.0
- old
+ new
@@ -1,6 +1,7 @@
require 'whyvalidationssuckin96/validation_builder'
+require 'whyvalidationssuckin96/validation_collection'
module WhyValidationsSuckIn96
module ValidationSupport
def self.included(klass_or_mod)
@@ -41,12 +42,13 @@
end
# An array of instances of all validations for this object
# @return [Array]
def all_validations
- @all_validations ||= self.class.validation_collection.collect do |(vc,opts)|
- vc.new(self, opts)
+ @all_validations ||= self.class.validation_collection.inject(ValidationCollection.new) do |vc, (v,opts)|
+ vc << v.new(self, opts)
+ vc
end
end
end # InstanceMethods
@@ -70,6 +72,6 @@
builder.create_validations!
end
end # ClassMethods
end # ValidationSupport
-end # WhyValidationsSuckIn96
\ No newline at end of file
+end # WhyValidationsSuckIn96