Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Time marshalling backported [#4286 state:committed]

Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information...
commit cf7ed7cf2dcd552d3b9e1076267ec0cc4c97564b 1 parent c1b2200
@spastorino spastorino authored wycats committed
Showing with 8 additions and 4 deletions.
  1. +8 −4 activesupport/lib/active_support/core_ext/time.rb
View
12 activesupport/lib/active_support/core_ext/time.rb
@@ -15,14 +15,18 @@ class << self
alias_method :_original_load, :_load
def _load(marshaled_time)
time = _original_load(marshaled_time)
- utc = time.send(:remove_instance_variable, '@marshal_with_utc_coercion') if time.instance_variable_defined?('@marshal_with_utc_coercion')
- utc ? time.utc : time
+ time.instance_eval do
+ if defined?(@marshal_with_utc_coercion)
+ val = remove_instance_variable("@marshal_with_utc_coercion")
+ end
+ val ? utc : self
+ end
end
end
-
+
alias_method :_original_dump, :_dump
def _dump(*args)
- obj = self.dup
+ obj = dup
obj.instance_variable_set('@marshal_with_utc_coercion', utc?)
obj._original_dump(*args)
end
Please sign in to comment.
Something went wrong with that request. Please try again.