Sha256: 015886658790e68d97aca76fc7be2c3b511c7bb8d6fefaa4442b28d5c2fa0abb

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

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

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
pager-engines-2.0.20080513 lib/engines/plugin/list.rb
railscart-0.0.1 starter-app/vendor/plugins/engines/lib/engines/plugin/list.rb
railscart-0.0.2 starter_app/vendor/plugins/engines/lib/engines/plugin/list.rb
railscart-0.0.3 starter_app/vendor/plugins/engines/lib/engines/plugin/list.rb
railscart-0.0.4 starter_app/vendor/plugins/engines/lib/engines/plugin/list.rb
spree-0.0.6 starter-app/vendor/plugins/engines/lib/engines/plugin/list.rb
spree-0.0.5 starter-app/vendor/plugins/engines/lib/engines/plugin/list.rb
spree-0.0.7 starter-app/vendor/plugins/engines/lib/engines/plugin/list.rb
spree-0.0.8 starter-app/vendor/plugins/engines/lib/engines/plugin/list.rb