Sha256: 4768541ac26f3c1f010e6d9794d52c1880a6d3f59f26289c0790cdb0f0be6343

Contents?: true

Size: 395 Bytes

Versions: 1

Compression:

Stored size: 395 Bytes

Contents

require 'happy_support/core_ext/object/to_param'

class Object
  def to_query(key)
    require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
    "#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}"
  end
end

class Array
  def to_query(key)
    prefix = "#{key}[]"
    collect { |value| value.to_query(prefix) }.join '&'
  end
end

class Hash
  alias_method :to_query, :to_param
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
happy_support-1.0.0 lib/happy_support/core_ext/object/to_query.rb