diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2013-11-05 19:22:03 -0800 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2013-11-05 19:22:03 -0800 |
commit | 134c1156dd5713da41c62ff798fe3979723e64cc (patch) | |
tree | 6e7f9540dafbec02d4ca6c2a7e75c637d86e1f1c /activesupport/CHANGELOG.md | |
parent | 44406d1e77061ce22effaae4698918c1f9f6271a (diff) | |
download | rails-134c1156dd5713da41c62ff798fe3979723e64cc.tar.gz rails-134c1156dd5713da41c62ff798fe3979723e64cc.tar.bz2 rails-134c1156dd5713da41c62ff798fe3979723e64cc.zip |
Fixed Object#as_json and Struct#as_json with options
These methods now takes the same options as Hash#as_json, for example:
struct = Struct.new(:foo, :bar).new
struct.foo = "hello"
struct.bar = "world"
json = struct.as_json(only: [:foo]) # => {foo: "hello"}
This is extracted from PR #11728 from @sergiocampama, see also the
discussion in #11460.
Diffstat (limited to 'activesupport/CHANGELOG.md')
-rw-r--r-- | activesupport/CHANGELOG.md | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index e718e79877..5d39fa39d9 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,13 @@ +* Fixed Object#as_json and Struct#as_json not working properly with options. They now take + the same options as Hash#as_json: + + struct = Struct.new(:foo, :bar).new + struct.foo = "hello" + struct.bar = "world" + json = struct.as_json(only: [:foo]) # => {foo: "hello"} + + *Sergio Campamá*, *Godfrey Chan* + * Added Numeric#in_milliseconds, like 1.hour.in_milliseconds, so we can feed them to JavaScript functions like getTime(). *DHH* |