Method: Protocol::HTTP::URL.assign
- Defined in:
- lib/protocol/http/url.rb
.assign(keys, value, parent) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/protocol/http/url.rb', line 83 def self.assign(keys, value, parent) top, *middle = keys middle.each_with_index do |key, index| if key.nil? or key.empty? parent = (parent[top] ||= Array.new) top = parent.size if nested = middle[index+1] and last = parent.last top -= 1 unless last.include?(nested) end else parent = (parent[top] ||= Hash.new) top = key end end parent[top] = value end |