Sha256: 914c0c0cc68eb8f4071dc9a3f769001ceb931646728ce9623dd52fe21da6a478

Contents?: true

Size: 966 Bytes

Versions: 9

Compression:

Stored size: 966 Bytes

Contents

# frozen_string_literal: true

module Qonfig
  module Commands
    # @api private
    # @since 0.1.0
    class Compose < Base
      # @return [Qonfig::DataSet]
      #
      # @api private
      # @since 0.1.0
      attr_reader :data_set_klass

      # @param data_set_klass [Qonfig::DataSet]
      #
      # @raise [Qonfig::ArgumentError]
      #
      # @api private
      # @since 0.1.0
      def initialize(data_set_klass)
        raise(
          Qonfig::ArgumentError,
          'Composed config class should be a subtype of Qonfig::DataSet'
        ) unless data_set_klass.is_a?(Class) && data_set_klass < Qonfig::DataSet

        @data_set_klass = data_set_klass
      end

      # @param settings [Qonfig::Settings]
      # @return [void]
      #
      # @api private
      # @since 0.1.0
      def call(settings)
        composite_settings = data_set_klass.new.settings

        settings.__append_settings__(composite_settings)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
qonfig-0.10.0 lib/qonfig/commands/compose.rb
qonfig-0.9.0 lib/qonfig/commands/compose.rb
qonfig-0.8.0 lib/qonfig/commands/compose.rb
qonfig-0.7.0 lib/qonfig/commands/compose.rb
qonfig-0.6.0 lib/qonfig/commands/compose.rb
qonfig-0.5.0 lib/qonfig/commands/compose.rb
qonfig-0.4.0 lib/qonfig/commands/compose.rb
qonfig-0.3.0 lib/qonfig/commands/compose.rb
qonfig-0.2.0 lib/qonfig/commands/compose.rb