Rails::Plugin (original) (raw)
Rails::Plugin is nothing more than a Rails::Engine, but since it’s loaded too late in the boot process, it does not have the same configuration powers as a bareRails::Engine.
Opposite to Rails::Railtie and Rails::Engine, you are not supposed to inherit fromRails::Plugin. Rails::Plugin is automatically configured to be an engine by simply placing inside vendor/plugins. Since this is done automatically, you actually cannot declare a Rails::Engine inside your Plugin, otherwise it would cause the same files to be loaded twice. This means that if you want to ship an Engine as gem it cannot be used as plugin and vice-versa.
Besides this conceptual difference, the only difference between Rails::Engine and Rails::Plugin is that plugins automatically load the file “init.rb” at the plugin root during the boot process.
Methods
A
C
G
I
N
R
Attributes
Class Public methods
all(list, paths)
Source: show
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) if global_plugins.include?(plugin.name) warn "WARNING: plugin #{plugin.name} from #{path} was not loaded. Plugin with the same name has been already loaded." next end global_plugins << plugin.name plugins << plugin end end
plugins.sort_by do |p| [list.index(p.name) || list.index(:all), p.name.to_s] end end
global_plugins()
Source: show
def self.global_plugins @global_plugins ||= [] end
inherited(base)
Source: show
def self.inherited(base) raise "You cannot inherit from Rails::Plugin" end
new(root)
Source: show
def initialize(root) @name = File.basename(root).to_sym config.root = root end
Instance Public methods
config()
Source: show
def config @config ||= Engine::Configuration.new end
railtie_name()
Source: show
def railtie_name name.to_s end