Class: Pendragon::Padrino::Router

Inherits:
Router
  • Object
show all
Defined in:
lib/pendragon/padrino/router.rb

Instance Attribute Summary collapse

Attributes inherited from Router

#current, #routes

Instance Method Summary collapse

Methods inherited from Router

#delete, #get, #head, #increment_order!, #initialize, #invoke, #post, #prepare!, #prepared?, #put, #recognize, #recognize_path, #reset!

Constructor Details

This class inherits a constructor from Pendragon::Router

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



6
7
8
# File 'lib/pendragon/padrino/router.rb', line 6

def configuration
  @configuration
end

Instance Method Details

#add(verb, path, options = {}, &block) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/pendragon/padrino/router.rb', line 8

def add(verb, path, options = {}, &block)
  route = Route.new(path, verb, options, &block)
  route.path_for_generation = options[:path_for_generation] if options[:path_for_generation]
  route.router = self
  routes << route
  route
end

#call(env) ⇒ Object



16
17
18
19
20
21
# File 'lib/pendragon/padrino/router.rb', line 16

def call(env)
  request = Rack::Request.new(env)
  [200, {}, recognize(request)]
rescue BadRequest, NotFound, MethodNotAllowed
  $!.call
end

#path(name, *args) ⇒ Object



23
24
25
26
27
# File 'lib/pendragon/padrino/router.rb', line 23

def path(name, *args)
  extract_with(name, *args) do |route, params, matcher|
    matcher.mustermann? ? matcher.expand(params) : route.path_for_generation
  end
end