Class: Kontrol::Router
- Inherits:
-
Object
- Object
- Kontrol::Router
- Defined in:
- lib/kontrol/router.rb
Instance Method Summary collapse
- #__find__(name) ⇒ Object
- #__recognize__(request) ⇒ Object
-
#initialize(&block) ⇒ Router
constructor
A new instance of Router.
- #method_missing(name, pattern, *args, &block) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Router
Returns a new instance of Router.
5 6 7 8 9 10 |
# File 'lib/kontrol/router.rb', line 5 def initialize(&block) @routes = [] @map = {} instance_eval(&block) if block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Method Details
#__find__(name) ⇒ Object
12 13 14 |
# File 'lib/kontrol/router.rb', line 12 def __find__(name) @map[name.to_sym] end |
#__recognize__(request) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/kontrol/router.rb', line 16 def __recognize__(request) @routes.each do |route| if match = route.recognize(request) return route, match end end return nil end |