Map::Param

Public Instance Methods

bytesize(string) click to toggle source
# File lib/map/params.rb, line 66
def bytesize(string) string.bytesize end
escape(s) click to toggle source
# File lib/map/params.rb, line 73
def escape(s)
  URI.encode_www_form_component(s)
end
param_for(value, prefix = nil) click to toggle source
# File lib/map/params.rb, line 44
def param_for(value, prefix = nil)
  case value
    when Array
      value.map { |v|
        param_for(v, "#{ prefix }[]")
      }.join("&")

    when Hash
      value.map { |k, v|
        param_for(v, prefix ? "#{ prefix }[#{ escape(k) }]" : escape(k))
      }.join("&")

    when String
      raise ArgumentError, "value must be a Hash" if prefix.nil?
      "#{ prefix }=#{ escape(value) }"

    else
      prefix
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.