Class: Toys::StandardMiddleware::ApplyConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/toys/standard_middleware/apply_config.rb

Overview

A middleware that applies the given block to all tool configurations.

Instance Method Summary collapse

Constructor Details

#initialize(parent_source: nil, source_name: nil, &block) ⇒ ApplyConfig

Create an ApplyConfig middleware

Parameters:

  • parent_source (Toys::SourceInfo) (defaults to: nil)

    The SourceInfo corresponding to the source where this block is provided, or nil (the default) if the block does not come from a Toys file.

  • source_name (String) (defaults to: nil)

    A user-visible name for the source, or nil to use the default.

  • block (Proc)

    The configuration to apply.



19
20
21
22
23
24
25
26
27
# File 'lib/toys/standard_middleware/apply_config.rb', line 19

def initialize(parent_source: nil, source_name: nil, &block)
  @source_info =
    if parent_source
      parent_source.proc_child(block, source_name: source_name)
    else
      SourceInfo.create_proc_root(block, source_name: source_name)
    end
  @block = block
end