diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-02-01 18:03:21 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-02-01 18:03:21 -0200 |
commit | a60ccadbf0307e43b726044a02612a7995c81c05 (patch) | |
tree | 803f82178ac4a22123aa5f91e3d00120e60b1e94 /activesupport/lib | |
parent | 682a579b25deb1142b8f445ad9ae0c661bc58564 (diff) | |
parent | c87b27ebde4c5a0bc172ffce59faaadb20301dec (diff) | |
download | rails-a60ccadbf0307e43b726044a02612a7995c81c05.tar.gz rails-a60ccadbf0307e43b726044a02612a7995c81c05.tar.bz2 rails-a60ccadbf0307e43b726044a02612a7995c81c05.zip |
Merge pull request #13911 from davidcelis/remove-bigdecimal-serialization
Deprecate custom BigDecimal serialization
Conflicts:
activesupport/CHANGELOG.md
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/big_decimal/conversions.rb | 15 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/big_decimal/yaml_conversions.rb | 13 |
2 files changed, 13 insertions, 15 deletions
diff --git a/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb b/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb index 39b8cea807..843c592669 100644 --- a/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb +++ b/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb @@ -1,22 +1,7 @@ require 'bigdecimal' require 'bigdecimal/util' -require 'yaml' class BigDecimal - YAML_MAPPING = { 'Infinity' => '.Inf', '-Infinity' => '-.Inf', 'NaN' => '.NaN' } - - def encode_with(coder) - string = to_s - coder.represent_scalar(nil, YAML_MAPPING[string] || string) - end - - # Backport this method if it doesn't exist - unless method_defined?(:to_d) - def to_d - self - end - end - DEFAULT_STRING_FORMAT = 'F' def to_formatted_s(*args) if args[0].is_a?(Symbol) diff --git a/activesupport/lib/active_support/core_ext/big_decimal/yaml_conversions.rb b/activesupport/lib/active_support/core_ext/big_decimal/yaml_conversions.rb new file mode 100644 index 0000000000..aa2ed4d6fb --- /dev/null +++ b/activesupport/lib/active_support/core_ext/big_decimal/yaml_conversions.rb @@ -0,0 +1,13 @@ +ActiveSupport::Deprecation.warn 'core_ext/big_decimal/yaml_conversions is deprecated and will be removed in the future.' + +require 'bigdecimal' +require 'yaml' + +class BigDecimal + YAML_MAPPING = { 'Infinity' => '.Inf', '-Infinity' => '-.Inf', 'NaN' => '.NaN' } + + def encode_with(coder) + string = to_s + coder.represent_scalar(nil, YAML_MAPPING[string] || string) + end +end |