Sha256: d23d890fcf51fb849218eebb65a5cf3453c69d74f74d16b76d546c35d9f12e97

Contents?: true

Size: 548 Bytes

Versions: 1

Compression:

Stored size: 548 Bytes

Contents

# frozen_string_literal: true

require 'rack/utils'

module CarrierWave::Cloudflare::URL
  class QueryString < Hash
    Parser = Object.new.tap do |obj|
      obj.extend(Rack::Utils)

      # these methods are private in Rack::Utils
      obj.singleton_class.instance_eval { public :build_query, :parse_query }
    end

    def initialize(query = '')
      super()
      merge!(Parser.parse_query(query))
    end

    def to_query
      result = Parser.build_query(self)
      result unless result.empty?
    end

    alias to_s to_query
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carrierwave-cloudflare-0.1.1 lib/carrierwave/cloudflare/url/query_string.rb