Sha256: f1a9e3b97eb447b318523e8a20973afd085fcdcf80647ced2e34b6a3e70d660e

Contents?: true

Size: 778 Bytes

Versions: 6

Compression:

Stored size: 778 Bytes

Contents

# frozen_string_literal: true

module Qonfig
  class DataSet
    # @api private
    # @since 0.2.0
    module 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)
                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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
qonfig-0.7.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.6.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.5.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.4.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.3.0 lib/qonfig/data_set/class_builder.rb
qonfig-0.2.0 lib/qonfig/data_set/class_builder.rb