Skip to content

Releases: yosiat/panko_serializer

v0.1.7

29 Sep 09:22
Compare
Choose a tag to compare

New Feature

Aliases #10

If we have attribute name which we want to expose to the client as another name, the simple way to do it is create new method attribute, for example:

class PostSerializer < Panko::Serializer
  attribute :published_at

  def published_at
    object.created_at
  end
end

The downside of this approach is that we get a direct hit on performance - we skip Panko Type Casting performance optimizations (Type Casting - Explanation).

With aliases, we can give created_at a new name, by creating an alias to it.

class PostSerializer < Panko::Serializer
  aliases created_at: :published_at
end

Changes

  • Cleaning benchmarks running code
  • Adding support to additional_types