Class: Wayfarer::Routing::Router
- Inherits:
-
Object
- Object
- Wayfarer::Routing::Router
- Extended by:
- Forwardable
- Defined in:
- lib/wayfarer/routing/router.rb
Constant Summary collapse
- ArgumentCountError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #draw(&block) ⇒ Object
-
#initialize ⇒ Router
constructor
A new instance of Router.
- #invoke(url, arguments) ⇒ Object
Constructor Details
#initialize ⇒ Router
Returns a new instance of Router.
12 13 14 |
# File 'lib/wayfarer/routing/router.rb', line 12 def initialize @blocks = [] end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
10 11 12 |
# File 'lib/wayfarer/routing/router.rb', line 10 def root @root end |
Instance Method Details
#draw(&block) ⇒ Object
16 17 18 |
# File 'lib/wayfarer/routing/router.rb', line 16 def draw(&block) @blocks.push(block) end |
#invoke(url, arguments) ⇒ Object
20 21 22 23 24 |
# File 'lib/wayfarer/routing/router.rb', line 20 def invoke(url, arguments) @root = Wayfarer::Routing::RootRoute.new @blocks.each { |block| Docile.dsl_eval(@root, *arguments, &block) } root.invoke(url) end |