Sha256: 747ade0d7703a955974bdd149f310e4ce4436a413f90536a6a63c1ddda2ee839

Contents?: true

Size: 875 Bytes

Versions: 8

Compression:

Stored size: 875 Bytes

Contents

module Skylight
  module Normalizers
    module ActiveModelSerializers
      class Render < Normalizer
        register "render.active_model_serializers"

        CAT = "view.render.active_model_serializers".freeze
        ANONYMOUS = "<Anonymous Serializer>".freeze

        def normalize(_trace, _name, payload)
          serializer_class = payload[:serializer]

          title = serializer_class.name || ANONYMOUS
          title = title.sub(/^ActiveModel::(Serializer::)?/, "")

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

          [CAT, title, desc]
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
skylight-5.1.0.beta lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.0.1 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.0.0 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.0.0.beta5 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.0.0.beta4 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.0.0.beta3 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.0.0.beta2 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.0.0.beta lib/skylight/normalizers/active_model_serializers/render.rb