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) ⇒ Object
Map array of names to available plugins.
Methods included from Conversions
Methods included from PluginsMap
Instance Method Details
#matching(type, list) ⇒ Array
Map array of names to available plugins.
15 16 17 18 19 |
# File 'lib/plugins/pluginator/extensions/matching.rb', line 15 def matching(type, list) list.map do |plugin| (plugins_map(type) || {})[string2class(plugin)] end end |
#matching!(type, list) ⇒ Object
Map array of names to available plugins. Behaves like ‘matching` but throws exceptions if can not find anything.
23 24 25 26 27 28 29 30 |
# File 'lib/plugins/pluginator/extensions/matching.rb', line 23 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 |