Sha256: 7947ac3b8ad7aa8176eb0df44777f47b90eece14e3c56ec84d7f4914662fa641

Contents?: true

Size: 769 Bytes

Versions: 7

Compression:

Stored size: 769 Bytes

Contents

# frozen_string_literal: true

module CleanArchitecture
  module Queries
    class HttpFailureCode
      def initialize(failure_details_type)
        @failure_details_type = failure_details_type
      end

      def to_sym
        code = FAILURE_DETAILS_TYPE_TO_STATUS_CODE[@failure_details_type.to_s.downcase]
        if code.nil?
          raise NotImplementedError,
                "cannot determine failure code for failure details type #{@failure_details_type}"
        end

        code
      end

      private

      FAILURE_DETAILS_TYPE_TO_STATUS_CODE = {
        'error' => :internal_server_error,
        'expectation_failed' => :expectation_failed,
        'not_found' => :not_found,
        'unauthorized' => :unauthorized
      }.freeze
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
clean-architecture-2.0.0 lib/clean_architecture/queries/http_failure_code.rb
clean-architecture-1.2.0 lib/clean_architecture/queries/http_failure_code.rb
clean-architecture-1.1.1 lib/clean_architecture/queries/http_failure_code.rb
clean-architecture-1.1.0 lib/clean_architecture/queries/http_failure_code.rb
clean-architecture-1.0.1 lib/clean_architecture/queries/http_failure_code.rb
clean-architecture-1.0.0 lib/clean_architecture/queries/http_failure_code.rb
clean-architecture-0.2.0 lib/clean_architecture/queries/http_failure_code.rb