High Performance JSON Serialization for ActiveRecord & Ruby Objects
this version includes changes from 0.5.3 to 0.5.6 - the versions between had small code cleanup.
Panko::Response
report in #32this version includes changes from 0.5.0 to 0.5.3
2017-03-04T12:45:23Z
instead of 2017-03-04T12:45:23.000Z
context
and scope
- passing MySerializer.new(user, scope: current_user)
will pass the scope to all nested associations. (same as context
)Panko::Response
is a nice utility, but building nested objects with JSON values can be really ugly and fast.
Let's take this example (from specs):
Panko::Response.new([
data: Panko::Response.new(
json_data: Panko::JsonValue.from({ a: 1 }.to_json),
foos: Panko::ArraySerializer.new(Foo.all, each_serializer: FooSerializer),
foo: Panko::JsonValue.from(FooSerializer.new.serialize_to_json(Foo.first)),
)
])
Will be changed to:
Panko::Response.create do |t|
[
{
data: t.value(
json_data: t.json({ a: 1 }.to_json),
foos: t.array_serializer(Foo.all, FooSerializer),
foo: t.serializer(Foo.first, FooSerializer)
)
}
]
end