Class: Primrose::Router

Inherits:
Object
  • Object
show all
Defined in:
lib/primrose/router.rb

Instance Method Summary collapse

Constructor Details

#initializeRouter

Returns a new instance of Router.



3
4
5
# File 'lib/primrose/router.rb', line 3

def initialize
  @routes = {}
end

Instance Method Details



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