Class: Hanami::CLI::CommandRegistry::Node Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/cli/command_registry.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Node of the registry

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ Node

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Node

Since:

  • 0.1.0


96
97
98
99
100
101
# File 'lib/hanami/cli/command_registry.rb', line 96

def initialize(parent = nil)
  @parent   = parent
  @children = Concurrent::Hash.new
  @aliases  = Concurrent::Hash.new
  @command  = nil
end

Instance Attribute Details

#aliasesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


88
89
90
# File 'lib/hanami/cli/command_registry.rb', line 88

def aliases
  @aliases
end

#childrenObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


84
85
86
# File 'lib/hanami/cli/command_registry.rb', line 84

def children
  @children
end

#commandObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


92
93
94
# File 'lib/hanami/cli/command_registry.rb', line 92

def command
  @command
end

#parentObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


80
81
82
# File 'lib/hanami/cli/command_registry.rb', line 80

def parent
  @parent
end

Instance Method Details

#alias!(key, child) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


123
124
125
# File 'lib/hanami/cli/command_registry.rb', line 123

def alias!(key, child)
  @aliases[key] = child
end

#aliases!(aliases) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


129
130
131
132
133
# File 'lib/hanami/cli/command_registry.rb', line 129

def aliases!(aliases)
  aliases.each do |a|
    parent.alias!(a, self)
  end
end

#leaf!(command) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


117
118
119
# File 'lib/hanami/cli/command_registry.rb', line 117

def leaf!(command)
  @command = command
end

#leaf?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 0.1.0


137
138
139
# File 'lib/hanami/cli/command_registry.rb', line 137

def leaf?
  !command.nil?
end

#lookup(token) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


111
112
113
# File 'lib/hanami/cli/command_registry.rb', line 111

def lookup(token)
  children[token] || aliases[token]
end

#put(parent, key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


105
106
107
# File 'lib/hanami/cli/command_registry.rb', line 105

def put(parent, key)
  children[key] ||= self.class.new(parent)
end