Sha256: 47a323ff22e291c3faa2105b1e9f1cca5a5b144e28d93f4374d182e9dc73164b

Contents?: true

Size: 918 Bytes

Versions: 20

Compression:

Stored size: 918 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

20 entries across 20 versions & 1 rubygems

Version Path
skylight-6.1.0.beta lib/skylight/normalizers/active_model_serializers/render.rb
skylight-6.0.4 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-6.0.3 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.3.5 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-6.0.2 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-6.0.1 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-6.0.0 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-6.0.0.beta2 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-6.0.0.beta lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.3.4 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.3.3 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.3.2 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.3.1 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.3.0 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.2.0 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.2.0.beta2 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.2.0.beta lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.1.1 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.1.0.beta3 lib/skylight/normalizers/active_model_serializers/render.rb
skylight-5.1.0.beta2 lib/skylight/normalizers/active_model_serializers/render.rb