Class: Knot::Dispatch::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/knot/dispatch/route.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_method, name, path, &block) ⇒ Route

Returns a new instance of Route.



8
9
10
# File 'lib/knot/dispatch/route.rb', line 8

def initialize(http_method, name, path, &block)
  @http_method, @name, @path, @block = http_method.to_s.upcase, name, path, block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



6
7
8
# File 'lib/knot/dispatch/route.rb', line 6

def block
  @block
end

#http_methodObject (readonly)

Returns the value of attribute http_method.



6
7
8
# File 'lib/knot/dispatch/route.rb', line 6

def http_method
  @http_method
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/knot/dispatch/route.rb', line 6

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/knot/dispatch/route.rb', line 6

def path
  @path
end

Instance Method Details

#match?(request) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/knot/dispatch/route.rb', line 12

def match?(request)
  http_method_match?(request) && Path.match?(@path, request.path)
end