From 4037e31d8874250e485ca6a27bd792a3beb13f76 Mon Sep 17 00:00:00 2001 From: Ernie Miller Date: Wed, 22 Aug 2012 10:27:42 -0400 Subject: Allow routing concerns to accept a callable This allows us to make alterations to the generated routes based on the scope of the current mapper, and otherwise allows us to move larger blocks of concerns out of the routes file, altogether. --- actionpack/lib/action_dispatch/routing/mapper.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index b52f66faf1..b1abbbe505 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -1613,8 +1613,8 @@ module ActionDispatch # end # # Any routing helpers can be used inside a concern. - def concern(name, &block) - @concerns[name] = block + def concern(name, callable = nil, &block) + @concerns[name] = callable || block end # Use the named concerns @@ -1631,7 +1631,7 @@ module ActionDispatch def concerns(*names) names.flatten.each do |name| if concern = @concerns[name] - instance_eval(&concern) + concern.call(self) else raise ArgumentError, "No concern named #{name} was found!" end @@ -1645,6 +1645,10 @@ module ActionDispatch @concerns = {} end + def current_scope + @scope + end + include Base include HttpHelpers include Redirection -- cgit v1.2.3