Class: ActionController::UrlEncodedPairParser
- Defined in:
- lib/action_controller/request.rb
Overview
:nodoc:
Constant Summary collapse
- KEY_REGEXP =
%r{([^\[\]=&]+)}
- BRACKETED_KEY_REGEXP =
%r{\[([^\[\]=&]+)\]}
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#top ⇒ Object
readonly
Returns the value of attribute top.
Instance Method Summary collapse
-
#initialize(pairs = []) ⇒ UrlEncodedPairParser
constructor
A new instance of UrlEncodedPairParser.
-
#parse(key, value) ⇒ Object
Parse the query string.
Constructor Details
#initialize(pairs = []) ⇒ UrlEncodedPairParser
Returns a new instance of UrlEncodedPairParser.
746 747 748 749 750 |
# File 'lib/action_controller/request.rb', line 746 def initialize(pairs = []) super('') @result = {} pairs.each { |key, value| parse(key, value) } end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
744 745 746 |
# File 'lib/action_controller/request.rb', line 744 def parent @parent end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
744 745 746 |
# File 'lib/action_controller/request.rb', line 744 def result @result end |
#top ⇒ Object (readonly)
Returns the value of attribute top.
744 745 746 |
# File 'lib/action_controller/request.rb', line 744 def top @top end |
Instance Method Details
#parse(key, value) ⇒ Object
Parse the query string
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 |
# File 'lib/action_controller/request.rb', line 756 def parse(key, value) self.string = key @top, @parent = result, nil # First scan the bare key key = scan(KEY_REGEXP) or return key = post_key_check(key) # Then scan as many nestings as present until eos? r = scan(BRACKETED_KEY_REGEXP) or return key = self[1] key = post_key_check(key) end bind(key, value) end |