Sha256: 6e5abc571918477feb7d9a65dba8727ff1ba52c2f27ce3702a3d608daf81b02f

Contents?: true

Size: 813 Bytes

Versions: 123

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true

require 'addressable'

module Addressable
  class URI
    # @return [ActiveSupport:HashWithIndifferentAccess]
    def hash_query_values
      (query_values || {}).with_indifferent_access
    end

    def query_value(*args)
      if args.count == 1
        query_value_get(*args)
      elsif args.count == 2
        query_value_set(*args)
      else
        raise ::ArgumentError, "#{object.class}.#{__method__}: wrong number of arguments" \
          " (given #{args.count}, expected 1..2)"
      end
    end

    private

    def query_value_get(name)
      hash_query_values[name]
    end

    def query_value_set(name, value)
      new_query_values = hash_query_values
      new_query_values[name] = value
      self.query_values = new_query_values

      self
    end
  end
end

Version data entries

123 entries across 123 versions & 2 rubygems

Version Path
eac_tools-0.76.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.76.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.75.2 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_ruby_utils-0.119.2 lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.75.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.75.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_ruby_utils-0.119.1 lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.74.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.74.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.73.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_ruby_utils-0.119.0 lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.72.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_ruby_utils-0.118.1 lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_ruby_utils-0.118.0 lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.70.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.70.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.69.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_ruby_utils-0.117.1 lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.69.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
eac_tools-0.68.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb