Module: Qonfig::DataSet::ClassBuilder Private

Defined in:
lib/qonfig/data_set/class_builder.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 0.2.0

Class Method Summary collapse

Class Method Details

.build_from_hash(hash) ⇒ Class<Qonfig::DataSet>

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.

Parameters:

  • hash (Hash)

Returns:

See Also:

Since:

  • 0.2.0



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/qonfig/data_set/class_builder.rb', line 14

def build_from_hash(hash)
  Class.new(Qonfig::DataSet).tap do |data_set_klass|
    hash.each_pair do |key, value|
      if value.is_a?(Hash) && value.any?
        sub_data_set_klass = build_from_hash(value)
        data_set_klass.setting(key) { compose sub_data_set_klass }
      else
        data_set_klass.setting key, value
      end
    end
  end
end