Class: Qonfig::Commands::Definition::AddNestedOption Private

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

inheritable=, inheritable?, #inheritable?, inherited

Constructor Details

#initialize(key, nested_definitions) ⇒ AddNestedOption

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

Parameters:

  • key (Symbol, String)
  • nested_definitions (Proc)

Raises:

Since:

  • 0.1.0



29
30
31
32
33
34
35
36
# File 'lib/qonfig/commands/definition/add_nested_option.rb', line 29

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

  @key = key
  @nested_data_set_klass = Class.new(Qonfig::DataSet).tap do |data_set|
    data_set.instance_eval(&nested_definitions)
  end
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.1.0



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

def key
  @key
end

#nested_data_set_klassClass<Qonfig::DataSet> (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:

Since:

  • 0.2.0



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

def nested_data_set_klass
  @nested_data_set_klass
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.1.0



44
45
46
47
48
49
# File 'lib/qonfig/commands/definition/add_nested_option.rb', line 44

def call(data_set, settings)
  nested_settings = nested_data_set_klass.new.settings

  nested_settings.__mutation_callbacks__.add(settings.__mutation_callbacks__)
  settings.__define_setting__(key, nested_settings)
end