Class: Primrose::Router
- Inherits:
-
Object
- Object
- Primrose::Router
- Defined in:
- lib/primrose/router.rb
Instance Method Summary collapse
-
#initialize ⇒ Router
constructor
A new instance of Router.
- #navigate(path) ⇒ Object
- #route(path, &block) ⇒ Object
Constructor Details
#initialize ⇒ Router
Returns a new instance of Router.
3 4 5 |
# File 'lib/primrose/router.rb', line 3 def initialize @routes = {} end |
Instance Method Details
#navigate(path) ⇒ Object
11 12 13 14 15 |
# File 'lib/primrose/router.rb', line 11 def navigate(path) return unless @routes[path] @routes[path].call end |
#route(path, &block) ⇒ Object
7 8 9 |
# File 'lib/primrose/router.rb', line 7 def route(path, &block) @routes[path] = block end |