Permalink
Browse files

TimeWithZone#freeze: preload instance variables so that we can actual…

…ly freeze
  • Loading branch information...
1 parent 93e1bff commit c79f1d281f1932d4203c7b5b5c793e370ed63838 @gbuesing gbuesing committed Oct 20, 2008
View
@@ -1,5 +1,7 @@
*Edge*
+* TimeWithZone#freeze: preload instance variables so that we can actually freeze [Geoff Buesing]
+
* Fix Brasilia timezone #1180 [Marcus Derencius, Kane]
* Time#advance recognizes fractional days and weeks. Deprecate Durations of fractional months and years #970 [Tom Lea]
@@ -277,9 +277,9 @@ def is_a?(klass)
end
alias_method :kind_of?, :is_a?
- # Neuter freeze because freezing can cause problems with lazy loading of attributes.
def freeze
- self
+ period; utc; time # preload instance variables before freezing
+ super
end
def marshal_dump
@@ -385,6 +385,19 @@ def test_marshal_dump_and_load_with_tzinfo_identifier
assert_equal @twz.inspect, mtime.inspect
end
end
+
+ def test_freeze
+ @twz.freeze
+ assert @twz.frozen?
+ end
+
+ def test_freeze_preloads_instance_variables
+ @twz.freeze
+ assert_nothing_raised do
+ @twz.period
+ @twz.time
+ end
+ end
uses_mocha 'TestDatePartValueMethods' do
def test_method_missing_with_non_time_return_value

0 comments on commit c79f1d2

Please sign in to comment.