Sha256: 426acdcb0dff06edf5290b6f812b2bb7aa88e9eeb5fe8939cb776fdee971ad49

Contents?: true

Size: 668 Bytes

Versions: 18

Compression:

Stored size: 668 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.2.0
module Qonfig::DataSet::ClassBuilder
  class << self
    # @param hash [Hash]
    # @return [Class<Qonfig::DataSet>]
    #
    # @see Qonfig::DataSet
    #
    # @api private
    # @since 0.2.0
    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
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
qonfig-0.28.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.27.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.26.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.25.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.24.1 lib/qonfig/data_set/class_builder.rb
qonfig-0.24.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.23.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.22.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.21.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.18.1 lib/qonfig/data_set/class_builder.rb
qonfig-0.18.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.17.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.16.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.15.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.14.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.13.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.12.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.11.0 lib/qonfig/data_set/class_builder.rb