class HttpRouter::Node::FreeRegex
Attributes
matcher[R]
Public Class Methods
new(router, parent, matcher)
click to toggle source
Calls superclass method
HttpRouter::Node.new
# File lib/http_router/node/free_regex.rb, line 5 def initialize(router, parent, matcher) @matcher = matcher super(router, parent) end
Public Instance Methods
to_code()
click to toggle source
# File lib/http_router/node/free_regex.rb, line 10 def to_code id = root.next_counter "whole_path#{id} = \"/\#{request.joined_path}\" if match = #{matcher.inspect}.match(whole_path#{id}) and match[0].size == whole_path#{id}.size request.extra_env['router.regex_match'] = match old_path = request.path request.path = [''] " << (use_named_captures? ? "match.names.size.times{|i| request.params << match[i + 1]} if match.respond_to?(:names) && match.names" : "") << " #{super} request.path = old_path request.extra_env.delete('router.regex_match') " << (use_named_captures? ? "params.slice!(-match.names.size, match.names.size)" : "" ) << " end" end
usable?(other)
click to toggle source
# File lib/http_router/node/free_regex.rb, line 28 def usable?(other) other.class == self.class && other.matcher == matcher end