# File lib/http_router/node/root.rb, line 6 def initialize(router) super(router, nil) @counter, @methods_module = 0, Module.new end
# File lib/http_router/node/root.rb, line 33 def compile(routes) routes.each {|route| add_route(route)} root.extend(root.methods_module) instance_eval "def call(request, &callback)\n#{to_code}\nnil\nend" @compiled = true end
# File lib/http_router/node/root.rb, line 25 def depth 0 end
# File lib/http_router/node/root.rb, line 19 def inject_root_ivar(obj) name = :"@ivar_#{@counter += 1}" root.instance_variable_set(name, obj) name end
# File lib/http_router/node/root.rb, line 29 def inspect_label "Root (#{@matchers.size} matchers)" end
# File lib/http_router/node/root.rb, line 15 def next_counter @counter += 1 end
# File lib/http_router/node/root.rb, line 11 def uncompile instance_eval "undef :call; def call(req); raise 'uncompiled root'; end", __FILE__, __LINE__ if compiled? end