diff options
author | José Valim <jose.valim@gmail.com> | 2011-06-08 23:34:30 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-06-08 23:34:30 -0700 |
commit | 0ad228027d4cca2b24a38aa84f6360f2732110d1 (patch) | |
tree | ad376cb7854a9feb899ce79b19e55582da79c962 /activesupport/lib/active_support/core_ext/date/freeze.rb | |
parent | 12245a33252c412da36e54671beac2f8f0325c65 (diff) | |
parent | dd3e7a6a349263e4f77736438b62d12c43c73ce3 (diff) | |
download | rails-0ad228027d4cca2b24a38aa84f6360f2732110d1.tar.gz rails-0ad228027d4cca2b24a38aa84f6360f2732110d1.tar.bz2 rails-0ad228027d4cca2b24a38aa84f6360f2732110d1.zip |
Merge pull request #1579 from bradleybuda/master
Date#freeze fails when called more than once in 1.8
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date/freeze.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date/freeze.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/freeze.rb b/activesupport/lib/active_support/core_ext/date/freeze.rb index 4edd715ba2..a731f8345e 100644 --- a/activesupport/lib/active_support/core_ext/date/freeze.rb +++ b/activesupport/lib/active_support/core_ext/date/freeze.rb @@ -5,7 +5,7 @@ # first call will result in a frozen object error since the memo # instance variable is uninitialized. # -# Work around by eagerly memoizing before freezing. +# Work around by eagerly memoizing before the first freeze. # # Ruby 1.9 uses a preinitialized instance variable so it's unaffected. # This hack is as close as we can get to feature detection: @@ -17,9 +17,11 @@ if RUBY_VERSION < '1.9' if frozen_object_error.message =~ /frozen/ class Date #:nodoc: def freeze - self.class.private_instance_methods(false).each do |m| - if m.to_s =~ /\A__\d+__\Z/ - instance_variable_set(:"@#{m}", [send(m)]) + unless frozen? + 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 |