Class: Lux::Application::MagicRoutes
- Defined in:
- lib/lux/application/lib/magic_routes.rb
Overview
Maps routes to method missing for cleaner interface
routes do |r|
map :about => 'root#about'
r.about 'root#about'
Instance Method Summary collapse
-
#initialize(app) ⇒ MagicRoutes
constructor
A new instance of MagicRoutes.
- #method_missing(route, *args, &block) ⇒ Object
Constructor Details
#initialize(app) ⇒ MagicRoutes
Returns a new instance of MagicRoutes.
7 8 9 |
# File 'lib/lux/application/lib/magic_routes.rb', line 7 def initialize app @app = app end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(route, *args, &block) ⇒ Object
11 12 13 |
# File 'lib/lux/application/lib/magic_routes.rb', line 11 def method_missing route, *args, &block @app.map [route, args.first || block] end |