Class: Hanami::Router::GlobbedPath

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/router/globbed_path.rb

Overview

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(http_method, path, to) ⇒ GlobbedPath

Returns a new instance of GlobbedPath.

Since:

  • 0.1.0



6
7
8
9
10
# File 'lib/hanami/router/globbed_path.rb', line 6

def initialize(http_method, path, to)
  @http_method = http_method
  @path = path
  @to = to
end

Instance Method Details

#endpoint_and_params(env) ⇒ Object

Since:

  • 0.1.0



12
13
14
15
16
17
18
19
20
# File 'lib/hanami/router/globbed_path.rb', line 12

def endpoint_and_params(env)
  return [] unless @http_method == env[::Rack::REQUEST_METHOD]

  if (match = @path.match(env[::Rack::PATH_INFO]))
    [@to, match.named_captures]
  else
    []
  end
end