Sha256: 910e07ce8973bc337062a1579bc925c87ccd5c07b1d68298dc616ec7505c8f1e

Contents?: true

Size: 498 Bytes

Versions: 7

Compression:

Stored size: 498 Bytes

Contents

# frozen_string_literal: true

module PicoApi
  module Entities
    class Errors < ROM::Struct
      class << self
        def call(error)
          class_name = error.class.name.demodulize
          error_entities = [
            Entities::Error.new(
              title: class_name.underscore,
              detail: error.message
            )
          ]
          new(errors: error_entities)
        end
      end

      attribute? :errors, ROM::Types::Array(Entities::Error)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pico_api-0.1.0 lib/pico_api/entities/errors.rb
pico_api-0.0.6 lib/pico_api/entities/errors.rb
pico_api-0.0.5 lib/pico_api/entities/errors.rb
pico_api-0.0.4 lib/pico_api/entities/errors.rb
pico_api-0.0.3 lib/pico_api/entities/errors.rb
pico_api-0.0.2 lib/pico_api/entities/errors.rb
pico_api-0.0.1 lib/pico_api/entities/errors.rb