Sha256: 1562163fa9161b9429f375f94f9ca9a2a59796ee55381c2cfaf8d14e6e7ae3a6

Contents?: true

Size: 599 Bytes

Versions: 5

Compression:

Stored size: 599 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]
        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

5 entries across 5 versions & 1 rubygems

Version Path
clean-architecture-0.1.0 lib/clean_architecture/queries/http_success_code.rb
clean-architecture-0.0.5 lib/clean_architecture/queries/http_success_code.rb
clean-architecture-0.0.4 lib/clean_architecture/queries/http_success_code.rb
clean-architecture-0.0.3 lib/clean_architecture/queries/http_success_code.rb
clean-architecture-0.0.1 lib/clean_architecture/queries/http_success_code.rb