Module: Pluginator::Extensions::FirstAsk
- Includes:
- PluginsMap
- Defined in:
- lib/plugins/pluginator/extensions/first_ask.rb
Overview
Extension to find first plugin that answers the question with true
Instance Method Summary collapse
-
#first_ask(type, method_name, *params) ⇒ Class
Call a method on plugin and return first one that returns ‘true`.
-
#first_ask!(type, method_name, *params) ⇒ Class
Call a method on plugin and return first one that returns ‘true`.
Methods included from PluginsMap
Methods included from Conversions
#class2name, #class2string, #string2class
Instance Method Details
#first_ask(type, method_name, *params) ⇒ Class
Call a method on plugin and return first one that returns ‘true`.
34 35 36 37 |
# File 'lib/plugins/pluginator/extensions/first_ask.rb', line 34 def first_ask(type, method_name, *params) @plugins[type] or return nil try_to_find(type, method_name, params) end |
#first_ask!(type, method_name, *params) ⇒ Class
Call a method on plugin and return first one that returns ‘true`. Behaves like `first_ask` but throws exceptions if can not find anything.
46 47 48 49 50 |
# File 'lib/plugins/pluginator/extensions/first_ask.rb', line 46 def first_ask!(type, method_name, *params) @plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys) try_to_find(type, method_name, params) or raise Pluginator::MissingPlugin.new(type, "first_ask: #{method_name}", plugins_map(type).keys) end |