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



233
234
235
# File 'lib/dry/cli/command_registry.rb', line 233

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



229
230
231
# File 'lib/dry/cli/command_registry.rb', line 229

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



239
240
241
# File 'lib/dry/cli/command_registry.rb', line 239

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



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

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