Class: Sputnik::CLI::NamespaceCommandLoader
- Inherits:
-
Object
- Object
- Sputnik::CLI::NamespaceCommandLoader
- Defined in:
- lib/sputnik/cli/namespace_command_loader.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(root = Sputnik::Plugin) ⇒ NamespaceCommandLoader
constructor
A new instance of NamespaceCommandLoader.
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 |