Class: Lux::Application::MagicRoutes

Inherits:
Object
  • Object
show all
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

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