Class: Siba::PluginLoader

Inherits:
Object
  • Object
show all
Includes:
FilePlug, LoggerPlug
Defined in:
lib/siba/plugins/plugin_loader.rb

Constant Summary collapse

InitClassName =
"Init"

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FilePlug

#siba_file, siba_file, siba_file=

Methods included from LoggerPlug

close, create, logger, #logger, opened?

Class Method Details

.loaderObject



10
11
12
# File 'lib/siba/plugins/plugin_loader.rb', line 10

def self.loader
  @loader ||= PluginLoader.new
end

Instance Method Details

#load(category, type, options) ⇒ Object

Raises:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/siba/plugins/plugin_loader.rb', line 14

def load(category, type, options)
  unless Siba::Plugins.valid_category? category
    raise PluginLoadError, "Incorrect plugin category '#{category}'. Available plugin categories are: #{Siba::Plugins.categories_str}"
  end

  raise PluginLoadError, "Options data is incorrect for #{plugin_category_and_type} plugin." unless options.is_a? Hash

  @category=category
  @type=type
  @options = options
  logger.debug "Loading #{plugin_category_and_type} plugin"

  require_plugin
  plugin_module = get_plugin_module
  plugin_type_module = get_plugin_type_module plugin_module
  init_class = get_plugin_init_class plugin_type_module
  init_plugin(init_class)
end