From 41c895c0d9575bc28fc849e05438c599a79cbde7 Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Sun, 1 Aug 2010 20:53:41 +1000 Subject: [PATCH] use restriction instead of check --- lib/validates_timeliness/validator.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/validates_timeliness/validator.rb b/lib/validates_timeliness/validator.rb index 5016c7e..f76bdfb 100644 --- a/lib/validates_timeliness/validator.rb +++ b/lib/validates_timeliness/validator.rb @@ -4,7 +4,7 @@ module ValidatesTimeliness class Validator < ActiveModel::EachValidator include Conversion - CHECKS = { + RESTRICTIONS = { :is_at => :==, :before => :<, :after => :>, @@ -38,10 +38,10 @@ module ValidatesTimeliness value = type_cast(value) - (CHECKS.keys & options.keys).each do |check| - check_value = type_cast(options[check]) - unless value.send(CHECKS[check], check_value) - return record.errors.add(attr_name, check, :restriction => check_value) + (RESTRICTIONS.keys & options.keys).each do |restriction| + restriction_value = type_cast(evaluate_option_value(options[restriction], record)) + unless value.send(RESTRICTIONS[restriction], restriction_value) + return record.errors.add(attr_name, restriction, :restriction => restriction_value) end end end