Skip to content

Commit

Permalink
defer running after_config hooks until after the object is allocated
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Aug 7, 2014
1 parent 42c569e commit 2296989
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions railties/lib/rails/application.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2296989

Please sign in to comment.