Sha256: ec937639e6bf8c1b35c1e245cc20b704464b5c31f061f08baadf97acfe300d17

Contents?: true

Size: 713 Bytes

Versions: 6

Compression:

Stored size: 713 Bytes

Contents

# frozen_string_literal: true

require "cgi"

module Hanami
  module Utils
    # URI query string transformations
    #
    # @since 1.2.0
    module QueryString
      # @since 1.3.1
      # @api private
      HASH_SEPARATOR = ","

      # Serialize input into a query string
      #
      # @param input [Object] the input
      #
      # @return [::String] the query string
      #
      # @since 1.2.0
      #
      # TODO: this is a very basic implementation that needs to be expanded
      def self.call(input)
        case input
        when ::Hash
          input.map { |key, value| "#{key}=#{value.inspect}" }.join(HASH_SEPARATOR)
        else
          input.to_s
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hanami-utils-1.3.5 lib/hanami/utils/query_string.rb
hanami-utils-1.3.4 lib/hanami/utils/query_string.rb
hanami-utils-1.3.3 lib/hanami/utils/query_string.rb
hanami-utils-1.3.2 lib/hanami/utils/query_string.rb
hanami-utils-2.0.0.alpha1 lib/hanami/utils/query_string.rb
hanami-utils-1.3.1 lib/hanami/utils/query_string.rb