Class: Musa::Variatio::Variatio::B Private

Inherits:
Object
  • Object
show all
Defined in:
lib/musa-dsl/generative/variatio.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.

Internal tree node for attribute application phase.

Manages execution of with_attributes blocks during variation generation. Coordinates attribute application across field hierarchy.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameter_name, options, affected_field_names, inner, blocks) ⇒ B

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



386
387
388
389
390
391
392
393
# File 'lib/musa-dsl/generative/variatio.rb', line 386

def initialize(parameter_name, options, affected_field_names, inner, blocks)
  @parameter_name = parameter_name
  @options = options
  @affected_field_names = affected_field_names
  @inner = inner

  @procedures = blocks.collect { |proc| Musa::Extension::SmartProcBinder::SmartProcBinder.new proc }
end

Instance Attribute Details

#affected_field_namesObject (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.



384
385
386
# File 'lib/musa-dsl/generative/variatio.rb', line 384

def affected_field_names
  @affected_field_names
end

#blocksObject (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.



384
385
386
# File 'lib/musa-dsl/generative/variatio.rb', line 384

def blocks
  @blocks
end

#innerObject (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.



384
385
386
# File 'lib/musa-dsl/generative/variatio.rb', line 384

def inner
  @inner
end

#optionsObject (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.



384
385
386
# File 'lib/musa-dsl/generative/variatio.rb', line 384

def options
  @options
end

#parameter_nameObject (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.



384
385
386
# File 'lib/musa-dsl/generative/variatio.rb', line 384

def parameter_name
  @parameter_name
end

Instance Method Details

#inspectObject Also known as: to_s

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.



420
421
422
# File 'lib/musa-dsl/generative/variatio.rb', line 420

def inspect
  "B name: #{@parameter_name}, options: #{@options}, affected_field_names: #{@affected_field_names}, blocks_size: #{@blocks.size}, inner: #{@inner}"
end

#run(parameters_with_depth, parent_parameters = nil) ⇒ 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.



395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/musa-dsl/generative/variatio.rb', line 395

def run(parameters_with_depth, parent_parameters = nil)
  parent_parameters ||= {}

  @options.each do |option|
    base = @parameter_name == :_maincontext ? parameters_with_depth : parameters_with_depth[@parameter_name][option]

    parameters = base.select { |k, _v| @affected_field_names.include? k }.merge(parent_parameters)
    parameters[@parameter_name] = option

    @procedures.each do |procedure_binder|
      procedure_binder.call **parameters
    end

    if @parameter_name == :_maincontext
      @inner.each do |inner|
        inner.run parameters_with_depth, parameters
      end
    else
      @inner.each do |inner|
        inner.run parameters_with_depth[@parameter_name][option], parameters
      end
    end
  end
end