rails/rails — pull request #12782 by chancancode (2013-11-06 03:23:17+00:00)
Title: 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.

/cc @jeremy