aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-08-28 22:36:10 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-08-28 22:36:10 -0700
commit85070b5e5679221be0f44ce1886be99432d53dd0 (patch)
treed6efbbde749206b86a592180046a24ba5a97938c /activesupport/lib/active_support/core_ext/date
parentc94f6ea2f30c4fa27cfe18db3af92b2633bcad36 (diff)
downloadrails-85070b5e5679221be0f44ce1886be99432d53dd0.tar.gz
rails-85070b5e5679221be0f44ce1886be99432d53dd0.tar.bz2
rails-85070b5e5679221be0f44ce1886be99432d53dd0.zip
Date#freeze bug doesn't affect Ruby 1.9
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date')
-rw-r--r--activesupport/lib/active_support/core_ext/date/behavior.rb18
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