Sha256: 7e12f5d70368cc0d9ed2b300fc4b92d71acae977647e1df841d355a2b1c96c95

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

# @api private
# @since 0.12.0
# @version 0.20.0
class Qonfig::Commands::Definition::LoadFromTOML < Qonfig::Commands::Base
  # @since 0.20.0
  self.inheritable = true

  # @return [String, Pathname]
  #
  # @api private
  # @since 0.12.0
  attr_reader :file_path

  # @return [Boolean]
  #
  # @api private
  # @since 0.12.0
  attr_reader :strict

  # @param file_path [String]
  # @option strict [Boolean]
  #
  # @api private
  # @since 0.12.0
  def initialize(file_path, strict: true)
    @file_path = file_path
    @strict = strict
  end

  # @param data_set [Qonfig::DataSet]
  # @param settings [Qonfig::Settings]
  # @return [void]
  #
  # @api private
  # @since 0.12.0
  def call(data_set, settings)
    toml_data = Qonfig::Loaders::TOML.load_file(file_path, fail_on_unexist: strict)
    toml_based_settings = build_data_set_klass(toml_data).new.settings
    settings.__append_settings__(toml_based_settings)
  end

  private

  # @param toml_data [Hash]
  # @return [Class<Qonfig::DataSet>]
  #
  # @api private
  # @since 0.12.0
  def build_data_set_klass(toml_data)
    Qonfig::DataSet::ClassBuilder.build_from_hash(toml_data)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
qonfig-0.28.0 lib/qonfig/plugins/toml/commands/definition/load_from_toml.rb
qonfig-0.27.0 lib/qonfig/plugins/toml/commands/definition/load_from_toml.rb
qonfig-0.26.0 lib/qonfig/plugins/toml/commands/definition/load_from_toml.rb
qonfig-0.25.0 lib/qonfig/plugins/toml/commands/definition/load_from_toml.rb
qonfig-0.24.1 lib/qonfig/plugins/toml/commands/definition/load_from_toml.rb
qonfig-0.24.0 lib/qonfig/plugins/toml/commands/definition/load_from_toml.rb
qonfig-0.23.0 lib/qonfig/plugins/toml/commands/definition/load_from_toml.rb