diff options
author | José Valim <jose.valim@gmail.com> | 2010-09-30 10:30:58 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-09-30 10:30:58 +0200 |
commit | 1ba22bcde1d5ee1e16e14d4d2dd23cbeb01cd59f (patch) | |
tree | 0c74273f34c20e56975a6b7845a034fa3df8c469 /railties/lib/rails/engine.rb | |
parent | 69f97f469747777ed1c457715f5361f6b8a0ab7b (diff) | |
parent | 9f569c60adb3505cd7ca1723481199bf26619038 (diff) | |
download | rails-1ba22bcde1d5ee1e16e14d4d2dd23cbeb01cd59f.tar.gz rails-1ba22bcde1d5ee1e16e14d4d2dd23cbeb01cd59f.tar.bz2 rails-1ba22bcde1d5ee1e16e14d4d2dd23cbeb01cd59f.zip |
Merge remote branch 'drogus/engines'
Diffstat (limited to 'railties/lib/rails/engine.rb')
-rw-r--r-- | railties/lib/rails/engine.rb | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 0620b8608e..9ae235b818 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -333,21 +333,22 @@ module Rails def namespace(mod) engine_name(generate_railtie_name(mod)) - _railtie = self name = engine_name - mod.singleton_class.instance_eval do - define_method(:_railtie) do - _railtie - end - - define_method(:table_name_prefix) do - "#{name}_" - end - end - self.routes.default_scope = {:module => name} - self.namespaced = true + + unless mod.respond_to?(:_railtie) + _railtie = self + mod.singleton_class.instance_eval do + define_method(:_railtie) do + _railtie + end + + define_method(:table_name_prefix) do + "#{name}_" + end + end + end end def namespaced? @@ -398,8 +399,10 @@ module Rails } end - def routes + def routes(&block) @routes ||= ActionDispatch::Routing::RouteSet.new + self.routes_draw_block = block if block_given? + @routes end def initializers @@ -446,6 +449,7 @@ module Rails end initializer :add_routing_paths do |app| + app.routes_reloader.blocks[routes] = routes_draw_block paths.config.routes.to_a.each do |route| app.routes_reloader.paths.unshift(route) if File.exists?(route) end @@ -498,6 +502,8 @@ module Rails end protected + attr_accessor :routes_draw_block + def find_root_with_flag(flag, default=nil) root_path = self.class.called_from |