Sha256: a8a25954b3b255e165bf6b53cedd9a9644dfec631462782deab2b9c19f76104d

Contents?: true

Size: 417 Bytes

Versions: 4

Compression:

Stored size: 417 Bytes

Contents

module FunWithJsonApi
  class ExceptionPayloadSerializer < ::ActiveModel::Serializer
    attributes :id, :status, :code, :title, :detail, :source

    def attributes(*)
      # Strips all empty values and empty arrays
      super.select { |_k, v| v.present? }
    end

    def source
      {
        pointer: object.pointer,
        parameter: object.parameter
      }.select { |_k, v| v.present? }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fun_with_json_api-0.0.14 lib/fun_with_json_api/exception_payload_serializer.rb
fun_with_json_api-0.0.13 lib/fun_with_json_api/exception_payload_serializer.rb
fun_with_json_api-0.0.11.3 lib/fun_with_json_api/exception_payload_serializer.rb
fun_with_json_api-0.0.11.2 lib/fun_with_json_api/exception_payload_serializer.rb