Method: ClassX::Pluggable#load_component

Defined in:
lib/classx/pluggable.rb

#load_component(type, hash) ⇒ Object



106
107
108
109
110
111
112
113
114
# File 'lib/classx/pluggable.rb', line 106

def load_component type, hash
  component = OpenStruct.new(hash.dup)
  mod = self.class.component_class_get(type, component.module, { :plugin_dir => self.plugin_dir })
  component.config ||= {}
  component.config[:context] = self
  instance = mod.new(component.config)
  instance.register
  logger.debug("ClassX::Pluggable: loaded #{type} #{component.module}, config=#{instance.inspect}")
end