Created
February 1, 2010 00:10
-
-
Save assaf/291332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Allows something like: | |
# map.admin "/:action/:id", controller: :admin, conditions: { host: "admin.example.com" } | |
module ActionController | |
module Routing | |
class RouteSet | |
def extract_request_environment(request) | |
{ method: request.method, host: request.host } | |
end | |
end | |
class Route | |
def recognition_conditions | |
result = ["(match = #{Regexp.new(recognition_pattern).inspect}.match(path))"] | |
result << "[conditions[:method]].flatten.include?(env[:method])" if conditions[:method] | |
result << "conditions[:host] == env[:host]" if conditions[:host] | |
result | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment