class Rails::Plugin
root during the boot process.
Rails::Plugin is that plugins automatically load the file “init.rb” at the plugin
Besides this conceptual difference, the only difference between Rails::Engine and
be used as plugin and vice-versa.
to be loaded twice. This means that if you want to ship an Engine as gem it cannot
declare a Rails::Engine inside your Plugin, otherwise it would cause the same files
placing inside vendor/plugins. Since this is done automatically, you actually cannot
Rails::Plugin. Rails::Plugin is automatically configured to be an engine by simply
Opposite to Rails::Railtie and Rails::Engine, you are not supposed to inherit from
Rails::Engine.
in the boot process, it does not have the same configuration powers as a bare
Rails::Plugin is nothing more than a Rails::Engine, but since it’s loaded too late
def self.all(list, paths)
def self.all(list, paths) plugins = [] paths.each do |path| Dir["#{path}/*"].each do |plugin_path| plugin = new(plugin_path) next unless list.include?(plugin.name) || list.include?(:all) plugins << plugin end end plugins.sort_by do |p| [list.index(p.name) || list.index(:all), p.name.to_s] end end
def self.inherited(base)
def self.inherited(base) raise "You cannot inherit from Rails::Plugin" end
def config
def config @config ||= Engine::Configuration.new end
def initialize(root)
def initialize(root) @name = File.basename(root).to_sym config.root = root end
def load_deprecated_tasks
def load_deprecated_tasks tasks = Dir["#{root}/{tasks,rails/tasks}/**/*.rake"].sort if tasks.any? ActiveSupport::Deprecation.warn "Rake tasks in #{tasks.to_sentence} are deprecated. Use lib/tasks instead" tasks.each { |ext| load(ext) } end end
def load_tasks
def load_tasks super load_deprecated_tasks end