From c12651104bd51aa1060d6d5db705a233950b0cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 20 Oct 2009 13:02:24 -0200 Subject: [PATCH] Type cast ActiveSupport::Duration before compiling it. --- lib/devise/active_record.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/devise/active_record.rb b/lib/devise/active_record.rb index f6d2cd7a..f6bd79bc 100644 --- a/lib/devise/active_record.rb +++ b/lib/devise/active_record.rb @@ -60,15 +60,19 @@ module Devise # Convert new keys to methods which overwrites Devise defaults options.each do |key, value| - if value.is_a?(Proc) - define_method key, &value - else - class_eval <<-END_EVAL, __FILE__, __LINE__ - def #{key} - #{value.inspect} - end - END_EVAL + case value + when Proc + define_method key, &value + next + when ActiveSupport::Duration + value = value.to_i end + + class_eval <<-END_EVAL, __FILE__, __LINE__ + def #{key} + #{value.inspect} + end + END_EVAL end end