The Plugin class should be an object which provides the following methods:

  • name - Used during initialisation to order the plugin (based on name and
                   the contents of <tt>config.plugins</tt>).
    
  • +valid?+ - Returns true if this plugin can be loaded.
  • load_paths - Each path within the returned array will be added to the $LOAD_PATH.
  • load - Finally ‘load’ the plugin.

These methods are expected by the Rails::Plugin::Locator and Rails::Plugin::Loader classes. The default implementation returns the lib directory as its load_paths, and evaluates init.rb when load is called.

You can also inspect the about.yml data programmatically:

  plugin = Rails::Plugin.new(path_to_my_plugin)
  plugin.about["author"] # => "James Adam"
  plugin.about["url"] # => "http://interblah.net"
Methods
Included Modules
Attributes
[R] directory
[R] name
Public Class methods
new(directory)
    # File railties/lib/rails/plugin.rb, line 24
24:     def initialize(directory)
25:       @directory = directory
26:       @name      = File.basename(@directory) rescue nil
27:       @loaded    = false
28:     end
Public Instance methods
<=>(other_plugin)
    # File railties/lib/rails/plugin.rb, line 52
52:     def <=>(other_plugin)
53:       name <=> other_plugin.name
54:     end
about()
    # File railties/lib/rails/plugin.rb, line 56
56:     def about
57:       @about ||= load_about_information
58:     end
load(initializer)

Evaluates a plugin‘s init.rb file.

    # File railties/lib/rails/plugin.rb, line 41
41:     def load(initializer)
42:       return if loaded?
43:       report_nonexistant_or_empty_plugin! unless valid?
44:       evaluate_init_rb(initializer)
45:       @loaded = true
46:     end
load_paths()

Returns a list of paths this plugin wishes to make available in $LOAD_PATH.

    # File railties/lib/rails/plugin.rb, line 35
35:     def load_paths
36:       report_nonexistant_or_empty_plugin! unless valid?
37:       has_lib_directory? ? [lib_path] : []
38:     end
loaded?()
    # File railties/lib/rails/plugin.rb, line 48
48:     def loaded?
49:       @loaded
50:     end
valid?()
    # File railties/lib/rails/plugin.rb, line 30
30:     def valid?
31:       File.directory?(directory) && (has_lib_directory? || has_init_file?)
32:     end