private Method

UrlEncodedPairParser.bind(key, value)

Bind a key (which may be nil for items in an array) to the provided value.

Source Code

# File action_controller/request.rb, line 669
def bind(key, value)
  if top.is_a? Array
    if key
      if top[-1].is_a?(Hash) && ! top[-1].key?(key)
        top[-1][key] = value
      else
        top << {key => value}.with_indifferent_access
        push top.last
      end
    else
      top << value
    end
  elsif top.is_a? Hash
    key = CGI.unescape(key)
    parent << (@top = {}) if top.key?(key) && parent.is_a?(Array)
    return top[key] ||= value
  else
    raise ArgumentError, "Don't know what to do: top is #{top.inspect}"
  end

  return value
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.