Sha256: 8473ee1837643d78f002d85b24006b82e80d5e707b113663ff514ef0745685d5

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

# @api private
# @since 0.25.0
class Qonfig::Commands::Definition::LoadFromVault < Qonfig::Commands::Base
  # @since 0.25.0
  self.inheritable = true

  # @return [String, Pathname]
  #
  # @api private
  # @since 0.25.0
  attr_reader :path

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

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

  # @param data_set [Qonfig::DataSet]
  # @param settings [Qonfig::Settings]
  # @return [void]
  #
  # @api private
  # @since 0.25.0
  def call(_data_set, settings)
    vault_data = Qonfig::Loaders::Vault.load_file(path, fail_on_unexist: strict)
    vault_based_settings = build_data_set_klass(vault_data).new.settings
    settings.__append_settings__(vault_based_settings)
  end

  private

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
qonfig-0.28.0 lib/qonfig/plugins/vault/commands/definition/load_from_vault.rb
qonfig-0.27.0 lib/qonfig/plugins/vault/commands/definition/load_from_vault.rb
qonfig-0.26.0 lib/qonfig/plugins/vault/commands/definition/load_from_vault.rb
qonfig-0.25.0 lib/qonfig/plugins/vault/commands/definition/load_from_vault.rb