Class: Usher::Node::RootIgnoringTrailingDelimiters
- Inherits:
-
Root
- Object
- Usher::Node
- Root
- Usher::Node::RootIgnoringTrailingDelimiters
- Defined in:
- lib/usher/node/root_ignoring_trailing_delimiters.rb
Instance Attribute Summary
Attributes inherited from Usher::Node
#default_terminates, #greedy, #meta, #normal, #parent, #request, #request_method_type, #request_methods, #terminates, #unique_terminating_routes, #value
Instance Method Summary collapse
-
#initialize(route_set, request_methods) ⇒ RootIgnoringTrailingDelimiters
constructor
A new instance of RootIgnoringTrailingDelimiters.
- #lookup(request_object, path) ⇒ Object
- #lookup_without_stripping ⇒ Object
Methods inherited from Root
#add, #add_meta, #delete, #route_set, #unique_routes
Methods inherited from Usher::Node
#add_meta, #add_terminate, #inspect, #remove_terminate
Constructor Details
#initialize(route_set, request_methods) ⇒ RootIgnoringTrailingDelimiters
Returns a new instance of RootIgnoringTrailingDelimiters.
7 8 9 10 |
# File 'lib/usher/node/root_ignoring_trailing_delimiters.rb', line 7 def initialize(route_set, request_methods) super @stripper = /#{Regexp.quote(route_set.delimiters.first)}$/ end |
Instance Method Details
#lookup(request_object, path) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/usher/node/root_ignoring_trailing_delimiters.rb', line 12 def lookup(request_object, path) if path.size > 1 new_path = path.gsub(@stripper, '') response = lookup_without_stripping(request_object, new_path) response.only_trailing_delimiters = (new_path.size != path.size) if response && response.succeeded? response else lookup_without_stripping(request_object, path) end end |
#lookup_without_stripping ⇒ Object
5 |
# File 'lib/usher/node/root_ignoring_trailing_delimiters.rb', line 5 alias_method :lookup_without_stripping, :lookup |