diff options
Diffstat (limited to 'railties/lib/rails/application')
-rw-r--r-- | railties/lib/rails/application/railties.rb | 31 | ||||
-rw-r--r-- | railties/lib/rails/application/routes_reloader.rb | 14 |
2 files changed, 40 insertions, 5 deletions
diff --git a/railties/lib/rails/application/railties.rb b/railties/lib/rails/application/railties.rb new file mode 100644 index 0000000000..d167d9bf4f --- /dev/null +++ b/railties/lib/rails/application/railties.rb @@ -0,0 +1,31 @@ +module Rails + class Application + class Railties + # TODO Write tests + def initialize(config) + @config = config + end + + def all(&block) + @all ||= railties + engines + plugins + @all.each(&block) if block + @all + end + + def railties + @railties ||= ::Rails::Railtie.subclasses.map(&:new) + end + + def engines + @engines ||= ::Rails::Engine.subclasses.map(&:new) + end + + def plugins + @plugins ||= begin + plugin_names = (@config.plugins || [:all]).map { |p| p.to_sym } + Plugin.all(plugin_names, @config.paths.vendor.plugins) + end + end + end + end +end
\ No newline at end of file diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb index 621bb1ccbd..6d61de2320 100644 --- a/railties/lib/rails/application/routes_reloader.rb +++ b/railties/lib/rails/application/routes_reloader.rb @@ -1,8 +1,8 @@ module Rails class Application class RoutesReloader - attr_reader :config - + # TODO Change config.action_dispatch.route_files to config.action_dispatch.routes_path + # TODO Write tests def initialize(config) @config, @last_change_at = config, nil end @@ -10,8 +10,8 @@ module Rails def changed_at routes_changed_at = nil - config.action_dispatch.route_files.each do |config| - config_changed_at = File.stat(config).mtime + files.each do |file| + config_changed_at = File.stat(file).mtime if routes_changed_at.nil? || config_changed_at > routes_changed_at routes_changed_at = config_changed_at @@ -26,7 +26,7 @@ module Rails routes.disable_clear_and_finalize = true routes.clear! - config.action_dispatch.route_files.each { |config| load(config) } + files.each { |file| load(file) } routes.finalize! nil @@ -41,6 +41,10 @@ module Rails reload! end end + + def files + @config.action_dispatch.route_files + end end end end
\ No newline at end of file |