module Serializer::Serializable::AbstractClassMethods

Overview

Abstract serializer static methods.

Defined in:

serializer/serializable.cr

Instance Method Summary

Instance Method Detail

def meta(_opts) #

Returns default meta options.

If this is empty and no additional meta-options are given - #meta key is avoided. To define own default meta options just override this in your serializer:

class UserSerializer < Serializer::Base(User)
  def self.meta(opts)
    {
      :status => "ok",
    } of Symbol => Serializer::MetaAny
  end
end

[View source]
def root_key : String | Nil #

Returns json root key.

Default data root key is "data". This behavior can be override by overriding this method. It can be omited by setting nil, but any meta-options and #meta keys will be ignored.

class UserSerializer < Serializer::Base(User)
  def self.root_key
    "user"
  end
end

[View source]