aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/initializable.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/initializable.rb')
-rw-r--r--railties/lib/rails/initializable.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/railties/lib/rails/initializable.rb b/railties/lib/rails/initializable.rb
index cea4a0fdf7..d91f67823f 100644
--- a/railties/lib/rails/initializable.rb
+++ b/railties/lib/rails/initializable.rb
@@ -64,10 +64,7 @@ module Rails
end
def initializers
- @initializers ||= begin
- initializers = self.class.initializers_chain
- Collection.new(initializers.map { |i| i.bind(self) })
- end
+ @initializers ||= self.class.initializers_for(self)
end
module ClassMethods
@@ -84,6 +81,10 @@ module Rails
initializers
end
+ def initializers_for(binding)
+ Collection.new(initializers_chain.map { |i| i.bind(binding) })
+ end
+
def initializer(name, opts = {}, &blk)
raise ArgumentError, "A block must be passed when defining an initializer" unless blk
initializers << Initializer.new(name, nil, opts, &blk)