Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

defer running after_config hooks until after the object is allocated

  • Loading branch information...
commit 22969898262b8c92bea1ac93b668a817c7511158 1 parent 42c569e
@tenderlove tenderlove authored
Showing with 22 additions and 7 deletions.
  1. +22 −7 railties/lib/rails/application.rb
View
29 railties/lib/rails/application.rb
@@ -90,6 +90,10 @@ def inherited(base)
Rails.app_class = base
end
+ def instance
+ super.run_load_hooks!
+ end
+
# Makes the +new+ method public.
#
# Note that Rails::Application inherits from Rails::Engine, which
@@ -116,22 +120,33 @@ def initialize(initial_variable_values = {}, &block)
@ordered_railties = nil
@railties = nil
@message_verifiers = {}
+ @ran_load_hooks = false
+
+ # are these actually used?
+ @initial_variable_values = initial_variable_values
+ @block = block
add_lib_to_load_path!
+ end
+
+ # Returns true if the application is initialized.
+ def initialized?
+ @initialized
+ end
+
+ def run_load_hooks! # :nodoc:
+ return self if @ran_load_hooks
+ @ran_load_hooks = true
ActiveSupport.run_load_hooks(:before_configuration, self)
- initial_variable_values.each do |variable_name, value|
+ @initial_variable_values.each do |variable_name, value|
if INITIAL_VARIABLES.include?(variable_name)
instance_variable_set("@#{variable_name}", value)
end
end
- instance_eval(&block) if block_given?
- end
-
- # Returns true if the application is initialized.
- def initialized?
- @initialized
+ instance_eval(&@block) if @block
+ self
end
# Implements call according to the Rack API. It simply
Please sign in to comment.
Something went wrong with that request. Please try again.