Sha256: 17ea0f005806626a8a9a0c198f9cc233ecefd87c3897590fc504e8123655f3ae

Contents?: true

Size: 754 Bytes

Versions: 2

Compression:

Stored size: 754 Bytes

Contents

# typed: false
# frozen_string_literal: true

require 'clean_architecture/types'
require 'dry/struct'

module CleanArchitecture
  module Entities
    class FailureDetails < Dry::Struct
      FailureTypes = Types::Strict::String.enum(
        'error',
        'expectation_failed',
        'not_found',
        'unauthorized'
      )

      attribute :type, FailureTypes
      attribute :message, Types::Strict::String
      attribute :other_properties, Types::Strict::Hash.default({}.freeze)

      def self.from_array(array)
        new(message: array.map(&:to_s).join(', '), other_properties: {}, type: 'error')
      end

      def self.from_string(string)
        new(message: string, other_properties: {}, type: 'error')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
clean-architecture-3.0.1 lib/clean_architecture/entities/failure_details.rb
clean-architecture-3.0.0 lib/clean_architecture/entities/failure_details.rb