Class: Qonfig::Commands::Definition::ExposeTOML Private

Inherits:
Base
  • Object
show all
Defined in:
lib/qonfig/plugins/toml/commands/definition/expose_toml.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.12.0

Version:

  • 0.20.0

Constant Summary collapse

EXPOSERS =

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

Returns:

  • (Hash)

Since:

  • 0.12.0

{ file_name: :file_name, env_key: :env_key }.freeze
EMPTY_TOML_DATA =

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

Returns:

  • (Hash)

Since:

  • 0.12.0

{}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

inheritable=, inheritable?, #inheritable?, inherited

Constructor Details

#initialize(file_path, strict: true, via:, env:) ⇒ ExposeTOML

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 ExposeTOML.

Parameters:

  • file_path (String)
  • strict (Hash) (defaults to: true)

    a customizable set of options

  • via (Hash)

    a customizable set of options

  • env (Hash)

    a customizable set of options

Options Hash (strict:):

  • (Boolean)

Options Hash (via:):

  • (Symbol)

Options Hash (env:):

  • (String, Symbol)

Raises:

Since:

  • 0.12.0



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/qonfig/plugins/toml/commands/definition/expose_toml.rb', line 53

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

  raise Qonfig::ArgumentError, ':env should be provided'  if env.to_s.empty?
  raise Qonfig::ArgumentError, 'used :via is unsupported' unless EXPOSERS.key?(via)

  @file_path = file_path
  @strict    = strict
  @via       = via
  @env       = env
end

Instance Attribute Details

#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.12.0



44
45
46
# File 'lib/qonfig/plugins/toml/commands/definition/expose_toml.rb', line 44

def env
  @env
end

#file_pathString, Pathname (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, Pathname)

Since:

  • 0.12.0



26
27
28
# File 'lib/qonfig/plugins/toml/commands/definition/expose_toml.rb', line 26

def file_path
  @file_path
end

#strictBoolean (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:

  • (Boolean)

Since:

  • 0.12.0



32
33
34
# File 'lib/qonfig/plugins/toml/commands/definition/expose_toml.rb', line 32

def strict
  @strict
end

#viaSymbol (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)

Since:

  • 0.12.0



38
39
40
# File 'lib/qonfig/plugins/toml/commands/definition/expose_toml.rb', line 38

def via
  @via
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:

Since:

  • 0.12.0



73
74
75
76
77
78
79
80
# File 'lib/qonfig/plugins/toml/commands/definition/expose_toml.rb', line 73

def call(data_set, settings)
  case via
  when EXPOSERS[:file_name]
    expose_file_name!(settings)
  when EXPOSERS[:env_key]
    expose_env_key!(settings)
  end
end