Module: Pluginator::Extensions::Matching
- Includes:
- Conversions, PluginsMap
- Defined in:
- lib/plugins/pluginator/extensions/matching.rb
Overview
Extension to select plugins that class name matches the list of string
Instance Method Summary collapse
-
#matching(type, list) ⇒ Array
Map array of names to available plugins.
-
#matching!(type, list) ⇒ Array
Map array of names to available plugins.
Methods included from Conversions
#class2name, #class2string, #string2class
Methods included from PluginsMap
Instance Method Details
#matching(type, list) ⇒ Array
Map array of names to available plugins.
34 35 36 37 38 |
# 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) ⇒ Array
Map array of names to available plugins. Behaves like ‘matching` but throws exceptions if can not find anything.
46 47 48 49 50 51 52 53 |
# 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 |