aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/engine.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/engine.rb')
-rw-r--r--railties/lib/rails/engine.rb44
1 files changed, 29 insertions, 15 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 0d01a818f5..eb6fcd5dd7 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -180,7 +180,7 @@ module Rails
# <tt>my_engine:install:assets</tt>
#
# Engine name is set by default based on class name. For <tt>MyEngine::Engine</tt> it will be
- # <tt>my_engine_engine</tt>. You can change it manually it manually using the <tt>engine_name</tt> method:
+ # <tt>my_engine_engine</tt>. You can change it manually using the <tt>engine_name</tt> method:
#
# module MyEngine
# class Engine < Rails::Engine
@@ -296,7 +296,7 @@ module Rails
# helper MyEngine::SharedEngineHelper
# end
#
- # If you want to include all of the engine's helpers, you can use #helpers method on egine's
+ # If you want to include all of the engine's helpers, you can use #helpers method on an engine's
# instance:
#
# class ApplicationController < ActionController::Base
@@ -305,7 +305,7 @@ module Rails
#
# It will include all of the helpers from engine's directory. Take into account that this does
# not include helpers defined in controllers with helper_method or other similar solutions,
- # only helpers defined in helpers directory will be included.
+ # only helpers defined in the helpers directory will be included.
#
# == Migrations & seed data
#
@@ -330,6 +330,14 @@ module Rails
autoload :Configuration, "rails/engine/configuration"
autoload :Railties, "rails/engine/railties"
+ def load_generators(app=self)
+ initialize_generators
+ railties.all { |r| r.load_generators(app) }
+ Rails::Generators.configure!(app.config.generators)
+ super
+ self
+ end
+
class << self
attr_accessor :called_from, :isolated
alias :isolated? :isolated
@@ -387,12 +395,20 @@ module Rails
delegate :middleware, :root, :paths, :to => :config
delegate :engine_name, :isolated?, :to => "self.class"
- def load_tasks(*)
+ def load_tasks(app=self)
+ railties.all { |r| r.load_tasks(app) }
super
paths["lib/tasks"].existent.sort.each { |ext| load(ext) }
end
-
+
+ def load_console(app=self)
+ railties.all { |r| r.load_console(app) }
+ super
+ end
+
def eager_load!
+ railties.all(&:eager_load!)
+
config.eager_load_paths.each do |load_path|
matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/
Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
@@ -522,15 +538,9 @@ module Rails
end
initializer :append_assets_path do |app|
- if app.config.assets.respond_to?(:prepend_path)
- app.config.assets.prepend_path(*paths["vendor/assets"].existent)
- app.config.assets.prepend_path(*paths["lib/assets"].existent)
- app.config.assets.prepend_path(*paths["app/assets"].existent)
- else
- app.config.assets.paths.unshift(*paths["vendor/assets"].existent)
- app.config.assets.paths.unshift(*paths["lib/assets"].existent)
- app.config.assets.paths.unshift(*paths["app/assets"].existent)
- end
+ app.config.assets.paths.unshift(*paths["vendor/assets"].existent)
+ app.config.assets.paths.unshift(*paths["lib/assets"].existent)
+ app.config.assets.paths.unshift(*paths["app/assets"].existent)
end
initializer :prepend_helpers_path do |app|
@@ -567,12 +577,16 @@ module Rails
protected
+ def initialize_generators
+ require "rails/generators"
+ end
+
def routes?
defined?(@routes)
end
def has_migrations?
- paths["db/migrate"].first.present?
+ paths["db/migrate"].existent.any?
end
def find_root_with_flag(flag, default=nil)