Class: HttpRouter::Glob

Inherits:
Variable show all
Defined in:
lib/http_router/glob.rb

Instance Attribute Summary

Attributes inherited from Variable

#matches_with, #name

Instance Method Summary collapse

Methods inherited from Variable

#===, #additional_matchers, #initialize

Constructor Details

This class inherits a constructor from HttpRouter::Variable

Instance Method Details

#matches(env, parts, whole_path) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/http_router/glob.rb', line 3

def matches(env, parts, whole_path)
  if @matches_with && match = @matches_with.match(parts.first)
    params = [parts.shift]
    while !parts.empty? and match = @matches_with.match(parts.first)
      params << parts.shift
    end
    return unless additional_matchers(env, params)
    whole_path.replace(parts.join('/'))
    params
  else
    params = parts.dup
    parts.clear
    params
  end
end