class Tengine::Core::Plugins
Attributes
modules[R]
Public Class Methods
new()
click to toggle source
# File lib/tengine/core/plugins.rb, line 6 def initialize @modules = [] end
Public Instance Methods
add(plugin_module)
click to toggle source
# File lib/tengine/core/plugins.rb, line 10 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) { || ... }
click to toggle source
# File lib/tengine/core/plugins.rb, line 18 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
Private Instance Methods
enable_plugin(plugin_module)
click to toggle source
# File lib/tengine/core/plugins.rb, line 36 def enable_plugin(plugin_module) if loader = find_sub_module(plugin_module, :DslLoader, :dsl_loader) # Tengine::Core::DslLoadingContext.send(:include, loader) Tengine::Core::Kernel.top.singleton_class.send(:include, loader) end if binder = find_sub_module(plugin_module, :DslBinder, :dsl_binder) # Tengine::Core::DslBindingContext.send(:include, binder) # Tengine::Core::Kernel.top.singleton_class.send(:include, binder) end end
find_sub_module(plugin_module, const_name, method_name)
click to toggle source
# File lib/tengine/core/plugins.rb, line 48 def find_sub_module(plugin_module, const_name, method_name) plugin_module.const_defined?(const_name) ? plugin_module.const_get(const_name) : plugin_module.respond_to?(method_name) ? plugin_module.send(method_name) : nil end