Skip to content

v0.4.4

Compare
Choose a tag to compare
@yosiat yosiat released this 23 Jun 11:25
· 182 commits to master since this release

Changes

  • Rubocop fixes to all code
  • Panko::Response enchantments - handling array and nice "DSL"

Panko::Response.create

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