class Qonfig::Commands::Definition::LoadFromTOML

@api private @since 0.12.0 @version 0.20.0

Attributes

file_path[R]

@return [String, Pathname]

@api private @since 0.12.0

strict[R]

@return [Boolean]

@api private @since 0.12.0

Public Class Methods

new(file_path, strict: true) click to toggle source

@param file_path [String] @option strict [Boolean]

@api private @since 0.12.0

# File lib/qonfig/plugins/toml/commands/definition/load_from_toml.rb, line 27
def initialize(file_path, strict: true)
  @file_path = file_path
  @strict = strict
end

Public Instance Methods

call(data_set, settings) click to toggle source

@param data_set [Qonfig::DataSet] @param settings [Qonfig::Settings] @return [void]

@api private @since 0.12.0

# File lib/qonfig/plugins/toml/commands/definition/load_from_toml.rb, line 38
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 Instance Methods

build_data_set_klass(toml_data) click to toggle source

@param toml_data [Hash] @return [Class<Qonfig::DataSet>]

@api private @since 0.12.0

# File lib/qonfig/plugins/toml/commands/definition/load_from_toml.rb, line 51
def build_data_set_klass(toml_data)
  Qonfig::DataSet::ClassBuilder.build_from_hash(toml_data)
end