Class: Hanami::Router::GlobbedPath

Inherits:
Object
  • Object
show all
Defined in:
gems/gems/hanami-router-2.1.0/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

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

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