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



110
111
112
113
114
115
116
117
118
# File 'lib/hanami/cli/command_registry.rb', line 110

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

  @before_callbacks = Utils::Callbacks::Chain.new
  @after_callbacks = Utils::Callbacks::Chain.new
end

Instance Attribute Details

#after_callbacksObject (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



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

def after_callbacks
  @after_callbacks
end

#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



94
95
96
# File 'lib/hanami/cli/command_registry.rb', line 94

def aliases
  @aliases
end

#before_callbacksObject (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



102
103
104
# File 'lib/hanami/cli/command_registry.rb', line 102

def before_callbacks
  @before_callbacks
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



90
91
92
# File 'lib/hanami/cli/command_registry.rb', line 90

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



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

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



86
87
88
# File 'lib/hanami/cli/command_registry.rb', line 86

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



140
141
142
# File 'lib/hanami/cli/command_registry.rb', line 140

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



146
147
148
149
150
# File 'lib/hanami/cli/command_registry.rb', line 146

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



134
135
136
# File 'lib/hanami/cli/command_registry.rb', line 134

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



154
155
156
# File 'lib/hanami/cli/command_registry.rb', line 154

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



128
129
130
# File 'lib/hanami/cli/command_registry.rb', line 128

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



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

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