Sha256: c02b71d01ab8097dfc2b0227d44d1b064a58f7c8d6040b555ae7135348b7fb00

Contents?: true

Size: 627 Bytes

Versions: 8

Compression:

Stored size: 627 Bytes

Contents

module ApiPack
  module Errors
    class ApiErrorsSerializer
      def initialize(body)
        @body = body
      end

      def serializer
        serializable
      end

      private

      attr_accessor :body

      def serializable
        return serializable_array if body[:details].is_a?(Array)

        serializable_object
      end

      def serializable_object
        {
          errors: [
            body
          ]
        }
      end

      def serializable_array
        {
          title: body[:title],
          status: body[:status],
          errors: body[:details]
        }
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
api_pack-1.3.1 lib/api_pack/errors/api_errors_serializer.rb
api_pack-1.2.1 lib/api_pack/errors/api_errors_serializer.rb
api_pack-1.1.4 lib/api_pack/errors/api_errors_serializer.rb
api_pack-1.1.3 lib/api_pack/errors/api_errors_serializer.rb
api_pack-1.1.2 lib/api_pack/errors/api_errors_serializer.rb
api_pack-1.1.1 lib/api_pack/errors/api_errors_serializer.rb
api_pack-1.0.1 lib/api_pack/errors/api_errors_serializer.rb
api_pack-1.0.0 lib/api_pack/errors/api_errors_serializer.rb