Skip to content

Instantly share code, notes, and snippets.

@abriening
Created June 24, 2010 04:40
Show Gist options
  • Save abriening/450985 to your computer and use it in GitHub Desktop.
Save abriening/450985 to your computer and use it in GitHub Desktop.
ActionController::Routing::RouteSet::Mapper
class ActionController::Routing::RouteSet::Mapper
def initialize(set)
@set = set
end
# Create an unnamed route with the provided +path+ and +options+. See
# SomeHelpfulUrl for an introduction to routes.
def connect(path, options = {})
puts "map.connect #{path}, #{options.inspect[1..-2]}"
@set.add_route(path, options)
end
def named_route(name, path, options = {})
puts "map.named_route #{name}, #{path}, #{options.inspect[1..-2]}"
@set.add_named_route(name, path, options)
end
def deprecated_named_route(name, deprecated_name, options = {})
puts "map.deprecated_named_route #{name}, #{deprecated_name}, #{options.inspect[1..-2]}"
@set.add_deprecated_named_route(name, deprecated_name)
end
# 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.
def root(*args, &proc)
puts "map.root #{args.inspect}"
super unless args.length >= 1 && proc.nil?
@set.add_named_route("root", *args)
end
deprecate :root => "(as the the label for a named route) will become a shortcut for map.connect '', so find another name"
def method_missing(route_name, *args, &proc)
puts "map.route_name #{args.inspect}"
super unless args.length >= 1 && proc.nil?
@set.add_named_route(route_name, *args)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment