From fae38cfecdec44322008bc3b860527982bc627c9 Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Thu, 12 Mar 2009 19:08:31 +1100 Subject: [PATCH] use value as raw_value if object doesn't have _before_type_cast method --- lib/validates_timeliness/validator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/validates_timeliness/validator.rb b/lib/validates_timeliness/validator.rb index bde905a..d072cf2 100644 --- a/lib/validates_timeliness/validator.rb +++ b/lib/validates_timeliness/validator.rb @@ -35,7 +35,7 @@ module ValidatesTimeliness def call(record, attr_name, value) value = record.class.parse_date_time(value, type, false) if value.is_a?(String) - raw_value = raw_value(record, attr_name) + raw_value = raw_value(record, attr_name) || value return if (raw_value.nil? && configuration[:allow_nil]) || (raw_value.blank? && configuration[:allow_blank]) @@ -49,7 +49,7 @@ module ValidatesTimeliness private def raw_value(record, attr_name) - record.send("#{attr_name}_before_type_cast") + record.send("#{attr_name}_before_type_cast") rescue nil end def validate_restrictions(record, attr_name, value)