Sha256: 94abf549893f81e649c5a330d37d2941b9212912ccf84bfce01ddd756e23a367

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      module RequestParams
        module Services
          class LogRequestParams
            include ConvenientService::Standard::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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
convenient_service-0.12.0 lib/convenient_service/examples/standard/request_params/services/log_request_params.rb
convenient_service-0.11.0 lib/convenient_service/examples/standard/request_params/services/log_request_params.rb
convenient_service-0.10.1 lib/convenient_service/examples/standard/request_params/services/log_request_params.rb
convenient_service-0.10.0 lib/convenient_service/examples/standard/request_params/services/log_request_params.rb
convenient_service-0.9.0 lib/convenient_service/examples/standard/request_params/services/log_request_params.rb
convenient_service-0.8.0 lib/convenient_service/examples/standard/request_params/services/log_request_params.rb
convenient_service-0.7.0 lib/convenient_service/examples/standard/request_params/services/log_request_params.rb
convenient_service-0.6.0 lib/convenient_service/examples/standard/request_params/services/log_request_params.rb