Class: Sputnik::CLI::NamespaceCommandLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/sputnik/cli/namespace_command_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(root = Sputnik::Plugin) ⇒ NamespaceCommandLoader

Returns a new instance of NamespaceCommandLoader.



4
5
6
# File 'lib/sputnik/cli/namespace_command_loader.rb', line 4

def initialize(root = Sputnik::Plugin)
  @root = root
end

Instance Method Details

#[](key) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/sputnik/cli/namespace_command_loader.rb', line 8

def [](key)
  key.split(/:+/).reduce(@root) do |cls, name|
    if cls.const_defined? name.capitalize
      cls.const_get name.capitalize
    else
      return nil
    end
  end
end