Class: Qonfig::Commands::ExposeSelf Private

Inherits:
Base
  • Object
show all
Defined in:
lib/qonfig/commands/expose_self.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.14.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(caller_location, env:) ⇒ ExposeSelf

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ExposeSelf.

Parameters:

  • caller_location (String)
  • env (Hash)

    a customizable set of options

Options Hash (env:):

  • (String, Symbol)

Since:

  • 0.14.0



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/qonfig/commands/expose_self.rb', line 23

def initialize(caller_location, env:)
  unless env.is_a?(Symbol) || env.is_a?(String)
    raise Qonfig::ArgumentError, ':env should be a string or a symbol'
  end

  if env.to_s.empty?
    raise Qonfig::ArgumentError, ':env should be provided'
  end

  @caller_location = caller_location
  @env = env
end

Instance Attribute Details

#caller_locationString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)

Since:

  • 0.14.0



10
11
12
# File 'lib/qonfig/commands/expose_self.rb', line 10

def caller_location
  @caller_location
end

#envSymbol, String (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Symbol, String)

Since:

  • 0.14.0



16
17
18
# File 'lib/qonfig/commands/expose_self.rb', line 16

def env
  @env
end

Instance Method Details

#call(data_set, settings) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

Raises:

Since:

  • 0.14.0



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/qonfig/commands/expose_self.rb', line 42

def call(data_set, settings)
  yaml_data = load_self_placed_yaml_data
  yaml_data_slice = yaml_data[env] || yaml_data[env.to_s] || yaml_data[env.to_sym]

  raise(
    Qonfig::ExposeError,
    "#{file_path} file does not contain settings with <#{env}> environment key!"
  ) unless yaml_data_slice

  raise(
    Qonfig::IncompatibleYAMLStructureError,
    'YAML content should have a hash-like structure'
  ) unless yaml_data_slice.is_a?(Hash)

  yaml_based_settings = build_data_set_klass(yaml_data_slice).new.settings
  settings.__append_settings__(yaml_based_settings)
end