Class: Skylight::Core::Normalizers::ActiveModelSerializers::Render Private

Inherits:
Normalizer
  • Object
show all
Defined in:
lib/skylight/core/normalizers/active_model_serializers/render.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

CAT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"view.render.active_model_serializers".freeze

Instance Attribute Summary

Attributes inherited from Normalizer

#config

Instance Method Summary collapse

Methods inherited from Normalizer

#initialize, #normalize_after, register

Constructor Details

This class inherits a constructor from Skylight::Core::Normalizers::Normalizer

Instance Method Details

#normalize(trace, name, payload) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/skylight/core/normalizers/active_model_serializers/render.rb', line 9

def normalize(trace, name, payload)
  serializer_class = payload[:serializer]

  title = serializer_class.name.sub(/^ActiveModel::(Serializer::)?/, '')

  if adapter_instance = payload[:adapter]
    adapter_name = adapter_instance.class.name
                      .sub(/^ActiveModel::Serializer::Adapter::/, '')
                      .sub(/^ActiveModelSerializers::Adapter::/, '')
    desc = "Adapter: #{adapter_name}"
  end

  [ CAT, title, desc ]
end