Class: Tengine::Core::Plugins
- Inherits:
-
Object
- Object
- Tengine::Core::Plugins
- Extended by:
- MethodTraceable
- Defined in:
- lib/tengine/core/plugins.rb
Instance Attribute Summary collapse
-
#modules ⇒ Object
readonly
Returns the value of attribute modules.
Instance Method Summary collapse
- #add(plugin_module) ⇒ Object
-
#initialize ⇒ Plugins
constructor
A new instance of Plugins.
- #notify(sender, msg) ⇒ Object
Methods included from MethodTraceable
Constructor Details
#initialize ⇒ Plugins
Returns a new instance of Plugins.
7 8 9 |
# File 'lib/tengine/core/plugins.rb', line 7 def initialize @modules = [] end |
Instance Attribute Details
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
5 6 7 |
# File 'lib/tengine/core/plugins.rb', line 5 def modules @modules end |
Instance Method Details
#add(plugin_module) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/tengine/core/plugins.rb', line 11 def add(plugin_module) return if modules.include?(plugin_module) Tengine::Core.stdout_logger.info("#{self.class.name}#add(#{plugin_module.name})") modules << plugin_module enable_plugin(plugin_module) plugin_module end |
#notify(sender, msg) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tengine/core/plugins.rb', line 19 def notify(sender, msg) if block_given? notify(sender, :"before_#{msg}") yield notify(sender, :"after_#{msg}") else modules.each do |m| m.notify(sender, msg) if m.respond_to?(:notify) end end end |