class Trenni::Query::Delegate

def append

def append
	if @index
		@current = @current.fetch(@index) do
			@current[@index] = []
		end
	end
	
	@index = @current.size
end

def assign(value, encoded)

def assign(value, encoded)
	if encoded
		value = ::URI.decode_www_form_component(value)
	end
	
	@current[@index] = value
	
	@current = @top
	@index = nil
end

def index(key)

def index(key)
	if @index
		@current = @current.fetch(@index) do
			@current[@index] = {}
		end
	end
	
	@index = key
end

def initialize(top = {})

def initialize(top = {})
	@top = top
	
	@current = @top
	@index = nil
end

def integer(key)

def integer(key)
	index(key.to_i)
end

def pair

def pair
	if @index
		@current[@index] = true
	end
	
	@current = @top
	@index = nil
end

def string(key, encoded)

def string(key, encoded)
	if encoded
		key = ::URI.decode_www_form_component(key)
	end
	
	index(key.to_sym)
end