1 module Radiant
2 module RoutingExtension
3
4 def self.included(base)
5 base.class_eval do
6 alias :draw_without_plugin_routes :draw
7 alias :draw :draw_with_plugin_routes
8 end
9 end
10
11 def draw_with_plugin_routes
12 draw_without_plugin_routes do |mapper|
13 add_extension_routes(mapper)
14 yield mapper
15 end
16 end
17
18 private
19
20 def add_extension_routes(mapper)
21 Extension.descendants.each do |ext|
22 ext.route_definitions.each do |block|
23 block.call(mapper)
24 end
25 end
26 end
27
28 end
29 end
30
31 ActionController::Routing::RouteSet.class_eval { include Radiant::RoutingExtension