Class: Rack::Way
- Inherits:
-
Object
show all
- Includes:
- Action
- Defined in:
- lib/rack-way.rb,
lib/rack-way/action.rb,
lib/rack-way/router.rb,
lib/rack-way/router/route.rb,
lib/rack-way/router/build_request.rb
Defined Under Namespace
Modules: Action
Classes: Router
Instance Method Summary
collapse
Methods included from Action
erb, #erb, #html, html, #html_response, html_response, included, #json, json, json_response, #json_response, #redirect_to, redirect_to, #response, response, #text, text, #text_response, text_response, view, view_response
Constructor Details
#initialize(router: Router.new) ⇒ Way
Returns a new instance of Way.
10
11
12
|
# File 'lib/rack-way.rb', line 10
def initialize(router: Router.new)
@router = router
end
|
Instance Method Details
#error(endpoint = -> {}, &block) ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/rack-way.rb', line 39
def error(endpoint = -> {}, &block)
if block_given?
@router.add_error(block)
else
@router.add_error(endpoint)
end
end
|
#http_router(&block) ⇒ Object
14
15
16
17
18
|
# File 'lib/rack-way.rb', line 14
def http_router(&block)
instance_eval(&block)
@router
end
|
#not_found(endpoint = -> {}, &block) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/rack-way.rb', line 31
def not_found(endpoint = -> {}, &block)
if block_given?
@router.add_not_found(block)
else
@router.add_not_found(endpoint)
end
end
|
#route ⇒ Object
20
21
22
|
# File 'lib/rack-way.rb', line 20
def route
@router.route
end
|
#scope(name, &block) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/rack-way.rb', line 24
def scope(name, &block)
@router.append_scope(name)
instance_eval(&block)
@router.clear_last_scope
end
|