提交 bf7fbe64 编写于 作者: G Godfrey Chan

Fixed a compatibility issue with the `Oj` gem

`Time#as_json`, `Date#as_json` and `DateTime#as_json` incorrectly depends on a
delegation that is set up in `active_support/json/encoding`. We cannot simply
require that file in `core_ext/object/json` because it would cause a circular
dependency problem (see #12203 for background). We should instead rely on AS's
autoload to load that file for us on-demand.

To trigger autoload correctly, we need to reference the `AS::JSON::Encoding`
constant instead of using the delegated version.

Fixes #16131.
上级 5de072c7
* Fixed a compatibility issue with the `Oj` gem when cherry-picking the file
`active_support/core_ext/object/json` without requiring `active_support/json`.
Fixes #16131.
*Godfrey Chan*
* Make `Hash#with_indifferent_access` copy the default proc too.
*arthurnn*, *Xanders*
......
......@@ -162,7 +162,7 @@ def as_json(options = nil) #:nodoc:
class Time
def as_json(options = nil) #:nodoc:
if ActiveSupport.use_standard_json_time_format
if ActiveSupport::JSON::Encoding.use_standard_json_time_format
xmlschema(ActiveSupport::JSON::Encoding.time_precision)
else
%(#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)})
......@@ -172,7 +172,7 @@ def as_json(options = nil) #:nodoc:
class Date
def as_json(options = nil) #:nodoc:
if ActiveSupport.use_standard_json_time_format
if ActiveSupport::JSON::Encoding.use_standard_json_time_format
strftime("%Y-%m-%d")
else
strftime("%Y/%m/%d")
......@@ -182,7 +182,7 @@ def as_json(options = nil) #:nodoc:
class DateTime
def as_json(options = nil) #:nodoc:
if ActiveSupport.use_standard_json_time_format
if ActiveSupport::JSON::Encoding.use_standard_json_time_format
xmlschema(ActiveSupport::JSON::Encoding.time_precision)
else
strftime('%Y/%m/%d %H:%M:%S %z')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册