Class: Tengine::Core::Plugins

Inherits:
Object
  • Object
show all
Extended by:
MethodTraceable
Defined in:
lib/tengine/core/plugins.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MethodTraceable

method_trace

Constructor Details

#initializePlugins

Returns a new instance of Plugins.



7
8
9
# File 'lib/tengine/core/plugins.rb', line 7

def initialize
  @modules = []
end

Instance Attribute Details

#modulesObject (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