Module: Pluginator::Extensions::FirstClass
- Includes:
- Conversions, PluginsMap
- Defined in:
- lib/plugins/pluginator/extensions/first_class.rb
Overview
Extension to find first plugin that class matches the string
Instance Method Summary collapse
-
#first_class(type, klass) ⇒ Class
Find first plugin that clas matches the given name.
-
#first_class!(type, klass) ⇒ Class
Find first plugin that clas matches the given name.
Methods included from Conversions
#class2name, #class2string, #string2class
Methods included from PluginsMap
Instance Method Details
#first_class(type, klass) ⇒ Class
Find first plugin that clas matches the given name.
35 36 37 |
# File 'lib/plugins/pluginator/extensions/first_class.rb', line 35 def first_class(type, klass) (plugins_map(type) || {})[string2class(klass)] end |
#first_class!(type, klass) ⇒ Class
Find first plugin that clas matches the given name. Behaves like ‘first_class` but throws exceptions if can not find anything.
45 46 47 48 49 50 |
# File 'lib/plugins/pluginator/extensions/first_class.rb', line 45 def first_class!(type, klass) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) klass = string2class(klass) plugins_map(type)[klass] or raise Pluginator::MissingPlugin.new(type, klass, plugins_map(type).keys) end |