module Pluginator::Extensions::Matching
Extension to select plugins that class name matches the list of string
Public Instance Methods
matching(type, list)
click to toggle source
Map array of names to available plugins.
@param type [String] name of type to search for plugins @param list [Array] list of plugin names to load @return [Array] list of loaded plugins
# File lib/plugins/pluginator/extensions/matching.rb, line 34 def matching(type, list) list.map do |plugin| (plugins_map(type) || {})[string2class(plugin)] end end
matching!(type, list)
click to toggle source
Map array of names to available plugins. Behaves like `matching` but throws exceptions if can not find anything. @param type [String] name of type to search for plugins @param list [Array] list of plugin names to load @return [Array] list of loaded plugins @raise [Pluginator::MissingPlugin] when can not find plugin
# File lib/plugins/pluginator/extensions/matching.rb, line 46 def matching!(type, list) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) list.map do |plugin| plugin = string2class(plugin) plugins_map(type)[plugin] or raise Pluginator::MissingPlugin.new(type, plugin, plugins_map(type).keys) end end