Sha256: e6980de3d068d11506093cb575aa6136229b851ab45da8155f20ca54aca99e52

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      module V1
        class RequestParams
          module Services
            class LogRequestParams
              include ConvenientService::Standard::V1::Config

              attr_reader :request, :params, :tag

              def initialize(request:, params:, tag: Constants::Tags::EMPTY)
                @request = request
                @params = params
                @tag = tag
              end

              def result
                Entities::Logger.log(message)

                success
              end

              private

              def message
                <<~MESSAGE
                  #{prefix}:
                  {
                  #{content}
                  }
                MESSAGE
              end

              def prefix
                text = "[Thread##{Thread.current.object_id}]"

                text += " [Request##{request.object_id}]"
                text += " [Params]"
                text += " [#{tag}]" unless tag.empty?

                text
              end

              def content
                params.map { |key, value| "  #{key}: #{value.inspect}" }.join(",\n")
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
convenient_service-0.17.0 lib/convenient_service/examples/standard/v1/request_params/services/log_request_params.rb
convenient_service-0.16.0 lib/convenient_service/examples/standard/v1/request_params/services/log_request_params.rb
convenient_service-0.15.0 lib/convenient_service/examples/standard/v1/request_params/services/log_request_params.rb
convenient_service-0.14.0 lib/convenient_service/examples/standard/v1/request_params/services/log_request_params.rb