Class: Shogun::Dispatch::Lookup

Inherits:
Object
  • Object
show all
Includes:
Adamantium
Defined in:
lib/shogun/dispatch/lookup.rb

Instance Method Summary collapse

Constructor Details

#initialize(routes:, verb:, path:) ⇒ Lookup

Returns a new instance of Lookup.



9
10
11
12
13
# File 'lib/shogun/dispatch/lookup.rb', line 9

def initialize(routes:, verb:, path:)
  @routes = routes
  @verb = verb
  @path = path
end

Instance Method Details

#payloadObject



20
21
22
23
24
25
26
# File 'lib/shogun/dispatch/lookup.rb', line 20

def payload
  if match.captures.any?
    match.names.zip(match.captures).to_h
  else
    {}
  end
end

#requestObject



15
16
17
# File 'lib/shogun/dispatch/lookup.rb', line 15

def request
  "#{@verb} #{@path}"
end

#to_routeObject



29
30
31
# File 'lib/shogun/dispatch/lookup.rb', line 29

def to_route
  regular || regexp || Route::Null.new
end