Sha256: d48da28e0971a963222f465b081a31646fbd9c5d0516d8cd55c2b589628171e2

Contents?: true

Size: 704 Bytes

Versions: 4

Compression:

Stored size: 704 Bytes

Contents

module RestClient
  module Jogger
    module Filters
      class QueryParameters < Base
        def filter
          return uri.to_s if uri.query.blank?
          uri.dup.tap { |u| u.query = parameters }.to_s
        end

        private

        def parameters
          CGI.parse(uri.query.to_s).each_with_object([]) do |(key, values), memo|
            values.each do |value|
              memo << "#{key}=#{filtered_value(key, value)}"
            end
          end.join('&')
        end

        def filtered_value(key, value)
          filters.include?(key.to_sym) ? filter_replacement : value
        end

        def uri
          @uri ||= URI.parse(data)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rest-client-jogger-1.3.0 lib/rest_client/jogger/filters/query_parameters.rb
rest-client-jogger-1.2.2 lib/rest_client/jogger/filters/query_parameters.rb
rest-client-jogger-1.2.1 lib/rest_client/jogger/filters/query_parameters.rb
rest-client-jogger-1.2.0 lib/rest_client/jogger/filters/query_parameters.rb