From c30ff6e9ab8cdfa2d6617260c570dbca3ff1fe1d Mon Sep 17 00:00:00 2001 From: Stephen Young Date: Thu, 21 May 2026 23:35:39 -0400 Subject: [PATCH] Remove unused ParamEncoder module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ParamEncoder was required but never called anywhere in the gem. Dead code — removing to reduce maintenance surface. --- lib/customerio.rb | 1 - lib/customerio/param_encoder.rb | 63 --------------------------------- 2 files changed, 64 deletions(-) delete mode 100644 lib/customerio/param_encoder.rb diff --git a/lib/customerio.rb b/lib/customerio.rb index 327b974..641113b 100644 --- a/lib/customerio.rb +++ b/lib/customerio.rb @@ -13,5 +13,4 @@ module Customerio require "customerio/requests/send_in_app_request" require "customerio/requests/trigger_broadcast_request" require "customerio/api" - require "customerio/param_encoder" end diff --git a/lib/customerio/param_encoder.rb b/lib/customerio/param_encoder.rb deleted file mode 100644 index b561553..0000000 --- a/lib/customerio/param_encoder.rb +++ /dev/null @@ -1,63 +0,0 @@ -# frozen_string_literal: true - -# Based on HTTParty's HashConversions: -# -# https://github.com/jnunemaker/httparty/blob/master/lib/httparty/hash_conversions.rb -# -# License: MIT https://github.com/jnunemaker/httparty/blob/master/MIT-LICENSE - -require "erb" - -module Customerio - class ParamEncoder - # @return This hash as a query string - # - # @example - # { name: "Bob", - # address: { - # street: '111 Ruby Ave.', - # city: 'Ruby Central', - # phones: ['111-111-1111', '222-222-2222'] - # } - # }.to_params - # #=> "name=Bob&address[city]=Ruby Central&..." - def self.to_params(hash) - hash.to_hash.map { |k, v| normalize_param(k, v) }.join.chop - end - - # @param key The key for the param. - # @param value The value for the param. - # - # @return This key value pair as a param - # - # @example normalize_param(:name, "Bob Jones") #=> "name=Bob%20Jones&" - def self.normalize_param(key, value) - param = String.new - stack = [] - - if value.respond_to?(:to_ary) - param << value.to_ary.map { |element| normalize_param("#{key}[]", element) }.join - elsif value.respond_to?(:to_hash) - stack << [key, value.to_hash] - else - param << "#{key}=#{escape_value(value)}&" - end - - stack.each do |parent, hash| - hash.each do |k, v| - if v.respond_to?(:to_hash) - stack << ["#{parent}[#{k}]", v.to_hash] - else - param << normalize_param("#{parent}[#{k}]", v) - end - end - end - - param - end - - def self.escape_value(value) - ERB::Util.url_encode(value.to_s) - end - end -end