aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-02-07 15:06:21 -0500
committerGitHub <noreply@github.com>2018-02-07 15:06:21 -0500
commit5ae2ecab6d3365f6f17e3c8cb298dfeeea113774 (patch)
tree504921f5f0fa56f69780cd0dcaea29b32615754c /activesupport/lib
parentc5d431e469505ec4438f9fd37530dd9c79c8a872 (diff)
parenta467c6bdd5722c09f5a15c0a7c5c40cc99c8be25 (diff)
downloadrails-5ae2ecab6d3365f6f17e3c8cb298dfeeea113774.tar.gz
rails-5ae2ecab6d3365f6f17e3c8cb298dfeeea113774.tar.bz2
rails-5ae2ecab6d3365f6f17e3c8cb298dfeeea113774.zip
Merge pull request #31923 from jdelStrother/duration-deserialization
Fix yaml deserialization of ActiveSupport::Duration
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/duration.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb
index fe1058762b..88897f811e 100644
--- a/activesupport/lib/active_support/duration.rb
+++ b/activesupport/lib/active_support/duration.rb
@@ -383,6 +383,14 @@ module ActiveSupport
to_i
end
+ def init_with(coder) #:nodoc:
+ initialize(coder["value"], coder["parts"])
+ end
+
+ def encode_with(coder) #:nodoc:
+ coder.map = { "value" => @value, "parts" => @parts }
+ end
+
# Build ISO 8601 Duration string for this duration.
# The +precision+ parameter can be used to limit seconds' precision of duration.
def iso8601(precision: nil)