diff options
author | David Celis <me@davidcel.is> | 2014-01-31 17:42:21 -0800 |
---|---|---|
committer | David Celis <me@davidcel.is> | 2014-02-01 10:45:51 -0800 |
commit | 85d820b1693a52faddf1f838512e132906272e41 (patch) | |
tree | 451e75dd1fe30610566906d8e94f64d3e5c6782c /activemodel | |
parent | 9b2a017aa82f95911280ed597e4bf3193c9399e9 (diff) | |
download | rails-85d820b1693a52faddf1f838512e132906272e41.tar.gz rails-85d820b1693a52faddf1f838512e132906272e41.tar.bz2 rails-85d820b1693a52faddf1f838512e132906272e41.zip |
Don't require BigDecimal serialization extension
Rails currently provides an extension to BigDecimal that redefines how
it is serialized to YAML. However, as noted in #12467, this does not
work as expected. When ActiveSupport is required, BigDecimal YAML
serialization does not maintain the object type. It instead ends up
serializing the number represented by the BigDecimal itself which, when
loaded by YAML later, becomes a Float:
```ruby
require 'yaml'
require 'bigdecimal'
yaml = BigDecimal('13.37').to_yaml
YAML.load(yaml).class
require 'active_support/all'
yaml = BigDecimal('13.37').to_yaml
YAML.load(yaml).class
```
@tenderlove posits that we should deprecate the custom BigDecimal
serialization and let Ruby handle it. For the time being, users who
require this serialization for backwards compatibility can manually
`require 'active_support/core_ext/big_decimal/yaml_conversions'`.
This will close #12467 and deprecate the custom BigDecimal#to_yaml.
Signed-off-by: David Celis <me@davidcel.is>
Diffstat (limited to 'activemodel')
0 files changed, 0 insertions, 0 deletions