Module: DockerBoss::ModuleManager

Defined in:
lib/docker_boss/module.rb

Class Method Summary collapse

Class Method Details

.<<(klass) ⇒ Object



7
8
9
10
# File 'lib/docker_boss/module.rb', line 7

def self.<<(klass)
  key = klass.name.split('::')[-1].downcase
  @modules[key] = klass
end

.[](key) ⇒ Object

Raises:

  • (IndexError)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/docker_boss/module.rb', line 12

def self.[](key)
  key = key.downcase

  unless @modules.has_key? key
    path = "docker_boss/module/#{key}"

    spec = Gem::Specification.find_by_path(path)
    unless spec.nil?
      activated = spec.activate
      DockerBoss.logger.info "Activated gem `#{spec.full_name}`" if activated
    end

    begin
      require path
    rescue LoadError
    end
  end

  raise IndexError, "Unknown module #{key}" unless @modules.has_key? key
  @modules[key]
end