Module: Rack::Mount::Recognition::Route
- Included in:
- Rack::Mount::Route
- Defined in:
- lib/rack/mount/recognition/route.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rack/mount/recognition/route.rb', line 14 def call(env) method = env[Const::REQUEST_METHOD] path = env[Const::PATH_INFO] if (@method.nil? || method == @method) && path =~ @path routing_args, param_matches = @defaults.dup, $~.captures @named_captures.each { |k, i| if v = param_matches[i] routing_args[k] = v end } env[Const::RACK_ROUTING_ARGS] = routing_args @app.call(env) else @throw end end |
#initialize(*args) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/rack/mount/recognition/route.rb', line 7 def initialize(*args) super @path_keys = path_keys(@path, %w( / )) @named_captures = named_captures(@path) end |
#path_keys_at(index) ⇒ Object
32 33 34 |
# File 'lib/rack/mount/recognition/route.rb', line 32 def path_keys_at(index) @path_keys[index] end |