Skip to content

Commit

Permalink
Nicer hash creation for route compile.
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviershay committed Jun 11, 2011
1 parent eda4431 commit 8b6d245
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/router.rb
Expand Up @@ -45,9 +45,8 @@ def match_route(path)
end

def compile(routes)
routes.inject({}) do |new_routes, (path, mappings)|
new_routes[Regexp.new("^%s$" % path)] = mappings
new_routes
end
Hash[routes.map {|path, mappings|
[Regexp.new("^%s$" % path), mappings]
}]
end
end

0 comments on commit 8b6d245

Please sign in to comment.