Class: HttpRouter::Node::Glob

Inherits:
HttpRouter::Node show all
Defined in:
lib/http_router/node/glob.rb

Direct Known Subclasses

GlobRegex

Instance Attribute Summary

Attributes inherited from HttpRouter::Node

#router

Instance Method Summary collapse

Methods inherited from HttpRouter::Node

#add_arbitrary, #add_destination, #add_free_match, #add_glob, #add_glob_regexp, #add_lookup, #add_match, #add_request, #add_spanning_match, #add_variable, #depth, #initialize, #inspect, #inspect_label, #inspect_matchers_body

Constructor Details

This class inherits a constructor from HttpRouter::Node

Instance Method Details

#node_to_codeObject



4
# File 'lib/http_router/node/glob.rb', line 4

alias_method :node_to_code, :to_code

#to_codeObject



9
10
11
12
13
14
15
16
17
# File 'lib/http_router/node/glob.rb', line 9

def to_code
  id = root.next_counter
  "request.params << (globbed_params#{id} = [])
    until request.path.empty?
      globbed_params#{id} << request.path.shift
      #{super}
    end
    request.path[0,0] = globbed_params#{id}"
end

#usable?(other) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/http_router/node/glob.rb', line 5

def usable?(other)
  other.class == self.class
end