aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/application.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2012-06-29 15:25:47 +0200
committerJosé Valim <jose.valim@gmail.com>2012-06-29 15:43:16 +0200
commit0470ddcf0301e537d5151d62177eadba5eae182d (patch)
tree0e338721443be0cee97735c2bfba65bb10d51412 /railties/lib/rails/application.rb
parente9e6f63d9c038273136d687e8055d03f43ea2fc1 (diff)
downloadrails-0470ddcf0301e537d5151d62177eadba5eae182d.tar.gz
rails-0470ddcf0301e537d5151d62177eadba5eae182d.tar.bz2
rails-0470ddcf0301e537d5151d62177eadba5eae182d.zip
Remove unnecessary Railties structure now that plugins are gone
Diffstat (limited to 'railties/lib/rails/application.rb')
-rw-r--r--railties/lib/rails/application.rb127
1 files changed, 68 insertions, 59 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index 32797ee657..1a993a25cb 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -53,7 +53,6 @@ module Rails
autoload :Bootstrap, 'rails/application/bootstrap'
autoload :Configuration, 'rails/application/configuration'
autoload :Finisher, 'rails/application/finisher'
- autoload :Railties, 'rails/application/railties'
autoload :RoutesReloader, 'rails/application/routes_reloader'
class << self
@@ -83,6 +82,61 @@ module Rails
@queue = nil
end
+ def initialized?
+ @initialized
+ end
+
+ # Implements call according to the Rack API. It simples
+ # dispatch the request to the underlying middleware stack.
+ def call(env)
+ env["ORIGINAL_FULLPATH"] = build_original_fullpath(env)
+ super(env)
+ end
+
+ # Reload application routes regardless if they changed or not.
+ def reload_routes!
+ routes_reloader.reload!
+ end
+
+ # Load the application and its railties tasks and invoke the registered hooks.
+ # Check <tt>Rails::Railtie.rake_tasks</tt> for more info.
+ def load_tasks(app=self)
+ initialize_tasks
+ super
+ self
+ end
+
+ # Load the application console and invoke the registered hooks.
+ # Check <tt>Rails::Railtie.console</tt> for more info.
+ def load_console(app=self)
+ initialize_console
+ super
+ self
+ end
+
+ # Load the application runner and invoke the registered hooks.
+ # Check <tt>Rails::Railtie.runner</tt> for more info.
+ def load_runner(app=self)
+ initialize_runner
+ super
+ self
+ end
+
+ # Stores some of the Rails initial environment parameters which
+ # will be used by middlewares and engines to configure themselves.
+ def env_config
+ @env_config ||= super.merge({
+ "action_dispatch.parameter_filter" => config.filter_parameters,
+ "action_dispatch.secret_token" => config.secret_token,
+ "action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions,
+ "action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local,
+ "action_dispatch.logger" => Rails.logger,
+ "action_dispatch.backtrace_cleaner" => Rails.backtrace_cleaner
+ })
+ end
+
+ ## Rails internal API
+
# This method is called just after an application inherits from Rails::Application,
# allowing the developer to load classes in lib and use them during application
# configuration.
@@ -106,18 +160,14 @@ module Rails
require environment if environment
end
- # Reload application routes regardless if they changed or not.
- def reload_routes!
- routes_reloader.reload!
- end
-
def routes_reloader #:nodoc:
@routes_reloader ||= RoutesReloader.new
end
- # Returns an array of file paths appended with a hash of directories-extensions
- # suitable for ActiveSupport::FileUpdateChecker API.
- def watchable_args
+ # Returns an array of file paths appended with a hash of
+ # directories-extensions suitable for ActiveSupport::FileUpdateChecker
+ # API.
+ def watchable_args #:nodoc:
files, dirs = config.watchable_files.dup, config.watchable_dirs.dup
ActiveSupport::Dependencies.autoload_paths.each do |path|
@@ -138,47 +188,6 @@ module Rails
self
end
- def initialized?
- @initialized
- end
-
- # Load the application and its railties tasks and invoke the registered hooks.
- # Check <tt>Rails::Railtie.rake_tasks</tt> for more info.
- def load_tasks(app=self)
- initialize_tasks
- super
- self
- end
-
- # Load the application console and invoke the registered hooks.
- # Check <tt>Rails::Railtie.console</tt> for more info.
- def load_console(app=self)
- initialize_console
- super
- self
- end
-
- # Load the application runner and invoke the registered hooks.
- # Check <tt>Rails::Railtie.runner</tt> for more info.
- def load_runner(app=self)
- initialize_runner
- super
- self
- end
-
- # Stores some of the Rails initial environment parameters which
- # will be used by middlewares and engines to configure themselves.
- def env_config
- @env_config ||= super.merge({
- "action_dispatch.parameter_filter" => config.filter_parameters,
- "action_dispatch.secret_token" => config.secret_token,
- "action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions,
- "action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local,
- "action_dispatch.logger" => Rails.logger,
- "action_dispatch.backtrace_cleaner" => Rails.backtrace_cleaner
- })
- end
-
# Returns the ordered railties for this application considering railties_order.
def ordered_railties #:nodoc:
@ordered_railties ||= begin
@@ -192,7 +201,7 @@ module Rails
end
end
- all = (railties.all - order)
+ all = (railties - order)
all.push(self) unless (all + order).include?(self)
order.push(:all) unless order.include?(:all)
@@ -216,11 +225,11 @@ module Rails
@queue ||= build_queue
end
- def build_queue # :nodoc:
+ def build_queue #:nodoc:
config.queue.new
end
- def to_app
+ def to_app #:nodoc:
self
end
@@ -228,20 +237,20 @@ module Rails
config.helpers_paths
end
- def call(env)
- env["ORIGINAL_FULLPATH"] = build_original_fullpath(env)
- super(env)
+ def railties #:nodoc:
+ @railties ||= Rails::Railtie.subclasses.map(&:instance) +
+ Rails::Engine.subclasses.map(&:instance)
end
protected
alias :build_middleware_stack :app
- def reload_dependencies?
+ def reload_dependencies? #:nodoc:
config.reload_classes_only_on_change != true || reloaders.map(&:updated?).any?
end
- def default_middleware_stack
+ def default_middleware_stack #:nodoc:
ActionDispatch::MiddlewareStack.new.tap do |middleware|
if rack_cache = config.action_controller.perform_caching && config.action_dispatch.rack_cache
require "action_dispatch/http/rack_cache"
@@ -315,7 +324,7 @@ module Rails
def initialize_runner #:nodoc:
end
- def build_original_fullpath(env)
+ def build_original_fullpath(env) #:nodoc:
path_info = env["PATH_INFO"]
query_string = env["QUERY_STRING"]
script_name = env["SCRIPT_NAME"]