Class: Dry::CLI::CommandRegistry::Chain Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/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.

Callbacks chain

Since:

  • 0.4.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChain

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 Chain.

Since:

  • 0.4.0



246
247
248
# File 'lib/dry/cli/command_registry.rb', line 246

def initialize
  @chain = Set.new
end

Instance Attribute Details

#chainObject (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.4.0



242
243
244
# File 'lib/dry/cli/command_registry.rb', line 242

def chain
  @chain
end

Instance Method Details

#append(&callback) ⇒ 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.4.0



252
253
254
# File 'lib/dry/cli/command_registry.rb', line 252

def append(&callback)
  chain.add(callback)
end

#run(context, *args) ⇒ 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.4.0



258
259
260
261
262
# File 'lib/dry/cli/command_registry.rb', line 258

def run(context, *args)
  chain.each do |callback|
    context.instance_exec(*args, &callback)
  end
end