Class: ActionController::Routing::RouteSet::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/action_controller/routing.rb

Overview

Mapper instances are used to build routes. The object passed to the draw block in config/routes.rb is a Mapper instance.

Mapper instances have relatively few instance methods, in order to avoid clashes with named routes.

Instance Method Summary collapse

Constructor Details

#initialize(set) ⇒ Mapper

:nodoc:



970
971
972
# File 'lib/action_controller/routing.rb', line 970

def initialize(set)
  @set = set
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(route_name, *args, &proc) ⇒ Object



996
997
998
999
# File 'lib/action_controller/routing.rb', line 996

def method_missing(route_name, *args, &proc)
  super unless args.length >= 1 && proc.nil?
  @set.add_named_route(route_name, *args)
end

Instance Method Details

#connect(path, options = {}) ⇒ Object

Create an unnamed route with the provided path and options. See SomeHelpfulUrl for an introduction to routes.



976
977
978
# File 'lib/action_controller/routing.rb', line 976

def connect(path, options = {})
  @set.add_route(path, options)
end

#deprecated_named_route(name, deprecated_name, options = {}) ⇒ Object



984
985
986
# File 'lib/action_controller/routing.rb', line 984

def deprecated_named_route(name, deprecated_name, options = {})
  @set.add_deprecated_named_route(name, deprecated_name)
end

#named_route(name, path, options = {}) ⇒ Object



980
981
982
# File 'lib/action_controller/routing.rb', line 980

def named_route(name, path, options = {})
  @set.add_named_route(name, path, options)
end

#root(*args, &proc) ⇒ Object

Added deprecation notice for anyone who already added a named route called “root”. It’ll be used as a shortcut for map.connect ” in Rails 2.0.



990
991
992
993
# File 'lib/action_controller/routing.rb', line 990

def root(*args, &proc)
  super unless args.length >= 1 && proc.nil?
  @set.add_named_route("root", *args)
end