class Shogun::Dispatch::Lookup

Attributes

routes[R]

Public Class Methods

new(routes:, verb:, path:) click to toggle source
# File lib/shogun/dispatch/lookup.rb, line 9
def initialize(routes:, verb:, path:)
  @routes = routes
  @verb = verb
  @path = path
end

Public Instance Methods

payload() click to toggle source
# File lib/shogun/dispatch/lookup.rb, line 20
def payload
  if match.captures.any?
    match.names.zip(match.captures).to_h
  else
    {}
  end
end
request() click to toggle source
# File lib/shogun/dispatch/lookup.rb, line 15
def request
  "#{@verb} #{@path}"
end
to_route() click to toggle source
# File lib/shogun/dispatch/lookup.rb, line 29
def to_route
  regular || regexp || Route::Null.new
end

Private Instance Methods

match() click to toggle source
# File lib/shogun/dispatch/lookup.rb, line 44
        def match
  request.match(pattern)
end
pattern() click to toggle source
# File lib/shogun/dispatch/lookup.rb, line 49
        def pattern
  routes.keys.detect(NO_MATCH) do |key|
    if key.is_a?(Regexp) then request =~ key else next end
  end
end
regexp() click to toggle source
# File lib/shogun/dispatch/lookup.rb, line 34
        def regexp
  routes[pattern]
end
regular() click to toggle source
# File lib/shogun/dispatch/lookup.rb, line 39
        def regular
  routes[request]
end