Sha256: 04cc94a6966c8f575f6e6bada9c33c4905590184bd8915592dbc870117bfdaed

Contents?: true

Size: 612 Bytes

Versions: 7

Compression:

Stored size: 612 Bytes

Contents

# frozen_string_literal: true

module CleanArchitecture
  module Queries
    class HttpSuccessCode
      def initialize(http_method)
        @http_method = http_method
      end

      def to_sym
        code = HTTP_METHOD_TO_SUCCESS_CODE[@http_method.to_s.upcase]
        if code.nil?
          raise NotImplementedError, "cannot determine success code for HTTP method #{@http_method}"
        end

        code
      end

      private

      HTTP_METHOD_TO_SUCCESS_CODE = {
        'GET' => :ok,
        'POST' => :created,
        'PUT' => :accepted,
        'DELETE' => :ok
      }.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_success_code.rb
clean-architecture-1.2.0 lib/clean_architecture/queries/http_success_code.rb
clean-architecture-1.1.1 lib/clean_architecture/queries/http_success_code.rb
clean-architecture-1.1.0 lib/clean_architecture/queries/http_success_code.rb
clean-architecture-1.0.1 lib/clean_architecture/queries/http_success_code.rb
clean-architecture-1.0.0 lib/clean_architecture/queries/http_success_code.rb
clean-architecture-0.2.0 lib/clean_architecture/queries/http_success_code.rb