Class: Uchi::Plugins
- Inherits:
-
Object
- Object
- Uchi::Plugins
- Defined in:
- lib/uchi/plugins.rb
Instance Attribute Summary collapse
-
#registered ⇒ Object
readonly
Returns the value of attribute registered.
Instance Method Summary collapse
- #hook(hook_name, **kwargs) ⇒ Object
-
#initialize ⇒ Plugins
constructor
A new instance of Plugins.
- #register(plugin_class) ⇒ Object
Constructor Details
#initialize ⇒ Plugins
Returns a new instance of Plugins.
13 14 15 |
# File 'lib/uchi/plugins.rb', line 13 def initialize @registered = [] end |
Instance Attribute Details
#registered ⇒ Object (readonly)
Returns the value of attribute registered.
3 4 5 |
# File 'lib/uchi/plugins.rb', line 3 def registered @registered end |
Instance Method Details
#hook(hook_name, **kwargs) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/uchi/plugins.rb', line 5 def hook(hook_name, **kwargs) registered.each do |plugin_class| next unless plugin_class.hooks_into?(hook_name) plugin_class.hook(hook_name, **kwargs) end end |
#register(plugin_class) ⇒ Object
17 18 19 |
# File 'lib/uchi/plugins.rb', line 17 def register(plugin_class) @registered << plugin_class end |