Sha256: 1280eece02f1595bd0c63c5ec51d79fd80d26695d50a13aafb3b350394888896
Contents?: true
Size: 1.15 KB
Versions: 9
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Qonfig module Commands # @api private # @since 0.1.0 class AddNestedOption < Base # @return [Symbol, String] # # @api private # @since 0.1.0 attr_reader :key # @return [Class<Qonfig::DataSet>] # # @api private # @since 0.2.0 attr_reader :nested_data_set_klass # @param key [Symbol, String] # @param nested_definitions [Proc] # # @raise [Qonfig::ArgumentError] # @raise [Qonfig::CoreMethodIntersectionError] # # @api private # @since 0.1.0 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 # @param settings [Qonfig::Settings] # @return [void] # # @api private # @since 0.1.0 def call(settings) nested_settings = nested_data_set_klass.new.settings settings.__define_setting__(key, nested_settings) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems