From 153ce54b1e9a84d362d24062c0496065407fe1f2 Mon Sep 17 00:00:00 2001 From: Peter Wagenet Date: Tue, 21 Jul 2009 16:54:31 -0700 Subject: [PATCH] Added ValidationErrors#count in order to play nicely with Rails --- lib/couchrest/validation/validation_errors.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/couchrest/validation/validation_errors.rb b/lib/couchrest/validation/validation_errors.rb index 4ddbb6e..7b7da0b 100644 --- a/lib/couchrest/validation/validation_errors.rb +++ b/lib/couchrest/validation/validation_errors.rb @@ -104,6 +104,13 @@ module CouchRest entries.empty? end + # Return size of errors hash + # + # Allows us to play nicely with Rails' helpers + def count + errors.size + end + def method_missing(meth, *args, &block) errors.send(meth, *args, &block) end