Class: Qonfig::Commands::Definition::ReDefineOption Private

Inherits:
Base
  • Object
show all
Defined in:
lib/qonfig/commands/definition/re_define_option.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.

Since:

  • 0.20.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

inheritable=, inheritable?, #inheritable?, inherited

Constructor Details

#initialize(key, value, nested_definitions) ⇒ ReDefineOption

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

Parameters:

  • key (Symbol, String)
  • value (Object)

Raises:

Since:

  • 0.20.0



35
36
37
38
39
40
41
42
43
# File 'lib/qonfig/commands/definition/re_define_option.rb', line 35

def initialize(key, value, nested_definitions)
  Qonfig::Settings::KeyGuard.prevent_incomparabilities!(key)

  @key = key
  @value = value
  @nested_data_set_klass = Class.new(Qonfig::DataSet).tap do |data_set|
    data_set.instance_eval(&nested_definitions)
  end if nested_definitions
end

Instance Attribute Details

#keySymbol, String (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.

Returns:

  • (Symbol, String)

Since:

  • 0.20.0



13
14
15
# File 'lib/qonfig/commands/definition/re_define_option.rb', line 13

def key
  @key
end

#nested_data_set_klassProc, NilClass (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.

Returns:

  • (Proc, NilClass)

Since:

  • 0.20.0



25
26
27
# File 'lib/qonfig/commands/definition/re_define_option.rb', line 25

def nested_data_set_klass
  @nested_data_set_klass
end

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

Returns:

  • (Object)

Since:

  • 0.20.0



19
20
21
# File 'lib/qonfig/commands/definition/re_define_option.rb', line 19

def value
  @value
end

Instance Method Details

#call(data_set, settings) ⇒ void

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.

This method returns an undefined value.

Parameters:

Since:

  • 0.20.0



51
52
53
54
55
56
57
58
59
# File 'lib/qonfig/commands/definition/re_define_option.rb', line 51

def call(data_set, settings)
  if nested_data_set_klass
    nested_settings = nested_data_set_klass.new.settings
    nested_settings.__mutation_callbacks__.add(settings.__mutation_callbacks__)
    settings.__define_setting__(key, nested_settings, with_redefinition: true)
  else
    settings.__define_setting__(key, value, with_redefinition: true)
  end
end