Chris@909: # The PluginList class is an array, enhanced to allow access to loaded plugins Chris@909: # by name, and iteration over loaded plugins in order of priority. This array is used Chris@909: # by Engines::RailsExtensions::RailsInitializer to create the Engines.plugins array. Chris@909: # Chris@909: # Each loaded plugin has a corresponding Plugin instance within this array, and Chris@909: # the order the plugins were loaded is reflected in the entries in this array. Chris@909: # Chris@909: # For more information, see the Rails module. Chris@909: module Engines Chris@909: class Plugin Chris@909: class List < Array Chris@909: # Finds plugins with the set with the given name (accepts Strings or Symbols), or Chris@909: # index. So, Engines.plugins[0] returns the first-loaded Plugin, and Engines.plugins[:engines] Chris@909: # returns the Plugin instance for the engines plugin itself. Chris@909: def [](name_or_index) Chris@909: if name_or_index.is_a?(Fixnum) Chris@909: super Chris@909: else Chris@909: self.find { |plugin| plugin.name.to_s == name_or_index.to_s } Chris@909: end Chris@909: end Chris@909: Chris@909: # Go through each plugin, highest priority first (last loaded first). Effectively, Chris@909: # this is like Engines.plugins.reverse Chris@909: def by_precedence Chris@909: reverse Chris@909: end Chris@909: end Chris@909: end Chris@909: end