diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-28 22:36:10 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-28 22:36:10 -0700 |
commit | 85070b5e5679221be0f44ce1886be99432d53dd0 (patch) | |
tree | d6efbbde749206b86a592180046a24ba5a97938c /activesupport | |
parent | c94f6ea2f30c4fa27cfe18db3af92b2633bcad36 (diff) | |
download | rails-85070b5e5679221be0f44ce1886be99432d53dd0.tar.gz rails-85070b5e5679221be0f44ce1886be99432d53dd0.tar.bz2 rails-85070b5e5679221be0f44ce1886be99432d53dd0.zip |
Date#freeze bug doesn't affect Ruby 1.9
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date/behavior.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/behavior.rb b/activesupport/lib/active_support/core_ext/date/behavior.rb index 50c77867f8..bd378eb375 100644 --- a/activesupport/lib/active_support/core_ext/date/behavior.rb +++ b/activesupport/lib/active_support/core_ext/date/behavior.rb @@ -21,15 +21,19 @@ module ActiveSupport #:nodoc: # # Ruby 1.9 uses a preinitialized instance variable so it's unaffected. # This hack is as close as we can get to feature detection: - if (Date.today.freeze.inspect rescue false) - def freeze #:nodoc: - self.class.private_instance_methods(false).each do |m| - if m.to_s =~ /\A__\d+__\Z/ - instance_variable_set(:"@#{m}", [send(m)]) + begin + ::Date.today.freeze.jd + rescue => frozen_object_error + if frozen_object_error.message =~ /frozen/ + def freeze #:nodoc: + self.class.private_instance_methods(false).each do |m| + if m.to_s =~ /\A__\d+__\Z/ + instance_variable_set(:"@#{m}", [send(m)]) + end end - end - super + super + end end end end |