Module: Qonfig::DSL Private

Included in:
Compacted, DataSet
Defined in:
lib/qonfig/dsl.rb,
lib/qonfig/plugins/toml/dsl.rb,
lib/qonfig/plugins/vault/dsl.rb

Overview

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

Since:

  • 0.25.0

Defined Under Namespace

Modules: Inheritance

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(child_klass) ⇒ 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.

rubocop:disable Layout/LineLength, Metrics/AbcSize

Parameters:

See Also:

Since:

  • 0.1.0

Version:

  • 0.20.0



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/qonfig/dsl.rb', line 19

def extended(child_klass)
  child_klass.instance_variable_set(:@definition_commands, Qonfig::CommandSet.new)
  child_klass.instance_variable_set(:@instance_commands, Qonfig::CommandSet.new)
  child_klass.instance_variable_set(:@predefined_validators, Qonfig::Validation::Collections::PredefinedRegistry.new)
  child_klass.instance_variable_set(:@validators, Qonfig::Validation::Collections::InstanceCollection.new)

  child_klass.singleton_class.prepend(Module.new do
    def inherited(child_klass)
      child_klass.instance_variable_set(:@definition_commands, Qonfig::CommandSet.new)
      child_klass.instance_variable_set(:@instance_commands, Qonfig::CommandSet.new)
      child_klass.instance_variable_set(:@predefined_validators, Qonfig::Validation::Collections::PredefinedRegistry.new)
      child_klass.instance_variable_set(:@validators, Qonfig::Validation::Collections::InstanceCollection.new)
      Qonfig::DSL::Inheritance.inherit(base: self, child: child_klass)
      super
    end
  end)
end

Instance Method Details

#compose(data_set_klass) ⇒ 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:

See Also:

  • Comamnds::Definition::Compose

Since:

  • 0.1.0



153
154
155
# File 'lib/qonfig/dsl.rb', line 153

def compose(data_set_klass)
  definition_commands << Qonfig::Commands::Definition::Compose.new(data_set_klass)
end

#define_validator(name, &validation_logic) ⇒ void

This method returns an undefined value.

Parameters:

  • name (String, Symbol)
  • validation_logic (Block)

See Also:

Since:

  • 0.20.0



107
108
109
110
111
# File 'lib/qonfig/dsl.rb', line 107

def define_validator(name, &validation_logic)
  Qonfig::Validation::Building::PredefinedBuilder.build(
    name, validation_logic, predefined_validators
  )
end

#definition_commandsQonfig::CommandSet

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:

Since:

  • 0.17.0



43
44
45
# File 'lib/qonfig/dsl.rb', line 43

def definition_commands
  @definition_commands
end

#expose_json(file_path, strict: true, via:, env:) ⇒ void

This method returns an undefined value.

Parameters:

  • file_path (String, Pathname)
  • 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:):

  • (Symbol, String)

See Also:

Since:

  • 0.14.0



241
242
243
244
245
# File 'lib/qonfig/dsl.rb', line 241

def expose_json(file_path, strict: true, via:, env:)
  definition_commands << Qonfig::Commands::Definition::ExposeJSON.new(
    file_path, strict: strict, via: via, env: env
  )
end

#expose_self(env:, format: :dynamic) ⇒ void

This method returns an undefined value.

Parameters:

  • env (Hash)

    a customizable set of options

  • format (Hash) (defaults to: :dynamic)

    a customizable set of options

Options Hash (env:):

  • (Symbol, String)

Options Hash (format:):

  • (Symbol, String)

See Also:

Since:

  • 0.14.0

Version:

  • 0.21.0



256
257
258
259
260
261
262
# File 'lib/qonfig/dsl.rb', line 256

def expose_self(env:, format: :dynamic)
  caller_location = ::Kernel.caller(1, 1).first

  definition_commands << Qonfig::Commands::Definition::ExposeSelf.new(
    caller_location, env: env, format: format
  )
end

#expose_toml(file_path, strict: true, via:, env:) ⇒ void

This method returns an undefined value.

Parameters:

  • file_path (String, Pathname)
  • 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:):

  • (Symbol, String)

See Also:

Since:

  • 0.12.0

Version:

  • 0.20.0



32
33
34
35
36
# File 'lib/qonfig/plugins/toml/dsl.rb', line 32

def expose_toml(file_path, strict: true, via:, env:)
  definition_commands << Qonfig::Commands::Definition::ExposeTOML.new(
    file_path, strict: strict, via: via, env: env
  )
end

#expose_vault(path, strict: true, via:, env:) ⇒ void

This method returns an undefined value.

Parameters:

  • path (String, Pathname)
  • 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:):

  • (Symbol, String)

See Also:

Since:

  • 0.25.0



30
31
32
33
34
# File 'lib/qonfig/plugins/vault/dsl.rb', line 30

def expose_vault(path, strict: true, via:, env:)
  definition_commands << Qonfig::Commands::Definition::ExposeVault.new(
    path, strict: strict, via: via, env: env
  )
end

#expose_yaml(file_path, strict: true, via:, env:) ⇒ void

This method returns an undefined value.

Parameters:

  • file_path (String, Pathname)
  • 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:):

  • (Symbol, String)

See Also:

Since:

  • 0.7.0



225
226
227
228
229
# File 'lib/qonfig/dsl.rb', line 225

def expose_yaml(file_path, strict: true, via:, env:)
  definition_commands << Qonfig::Commands::Definition::ExposeYAML.new(
    file_path, strict: strict, via: via, env: env
  )
end

#freeze_state!void

This method returns an undefined value.

See Also:

Since:

  • 0.19.0



288
289
290
# File 'lib/qonfig/dsl.rb', line 288

def freeze_state!
  instance_commands << Qonfig::Commands::Instantiation::FreezeState.new
end

#instance_commandsQonfig::CommandSet

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:

Since:

  • 0.17.0



51
52
53
# File 'lib/qonfig/dsl.rb', line 51

def instance_commands
  @instance_commands
end

#load_from_env(convert_values: false, prefix: nil, trim_prefix: false) ⇒ void

This method returns an undefined value.

Parameters:

  • convert_values (Hash) (defaults to: false)

    a customizable set of options

  • prefix (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (convert_values:):

  • (Boolean)

Options Hash (prefix:):

  • (NilClass, String, Regexp)

See Also:

Since:

  • 0.2.0



195
196
197
198
199
200
201
# File 'lib/qonfig/dsl.rb', line 195

def load_from_env(convert_values: false, prefix: nil, trim_prefix: false)
  definition_commands << Qonfig::Commands::Definition::LoadFromENV.new(
    convert_values: convert_values,
    prefix: prefix,
    trim_prefix: trim_prefix
  )
end

#load_from_json(file_path, strict: true) ⇒ void

This method returns an undefined value.

Parameters:

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

    a customizable set of options

Options Hash (strict:):

  • (Boolean)

See Also:

Since:

  • 0.5.0



211
212
213
# File 'lib/qonfig/dsl.rb', line 211

def load_from_json(file_path, strict: true)
  definition_commands << Qonfig::Commands::Definition::LoadFromJSON.new(file_path, strict: strict)
end

#load_from_self(format: :dynamic) ⇒ void

This method returns an undefined value.

Parameters:

  • format (Hash) (defaults to: :dynamic)

    a customizable set of options

Options Hash (format:):

  • (Symbol, String)

See Also:

Since:

  • 0.2.0

Version:

  • 0.21.0



179
180
181
182
183
184
185
# File 'lib/qonfig/dsl.rb', line 179

def load_from_self(format: :dynamic)
  caller_location = ::Kernel.caller(1, 1).first

  definition_commands << Qonfig::Commands::Definition::LoadFromSelf.new(
    caller_location, format: format
  )
end

#load_from_toml(file_path, strict: true) ⇒ void

This method returns an undefined value.

Parameters:

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

    a customizable set of options

Options Hash (strict:):

  • (Boolean)

See Also:

Since:

  • 0.12.0

Version:

  • 0.20.0



15
16
17
18
19
# File 'lib/qonfig/plugins/toml/dsl.rb', line 15

def load_from_toml(file_path, strict: true)
  definition_commands << Qonfig::Commands::Definition::LoadFromTOML.new(
    file_path, strict: strict
  )
end

#load_from_vault(path, strict: true) ⇒ void

This method returns an undefined value.

Parameters:

  • path (String, Pathname)
  • strict (Hash) (defaults to: true)

    a customizable set of options

Options Hash (strict:):

  • (Boolean)

See Also:

Since:

  • 0.25.0



14
15
16
17
18
# File 'lib/qonfig/plugins/vault/dsl.rb', line 14

def load_from_vault(path, strict: true)
  definition_commands << Qonfig::Commands::Definition::LoadFromVault.new(
    path, strict: strict
  )
end

#load_from_yaml(file_path, strict: true) ⇒ void

This method returns an undefined value.

Parameters:

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

    a customizable set of options

Options Hash (strict:):

  • (Boolean)

See Also:

Since:

  • 0.2.0



165
166
167
168
169
# File 'lib/qonfig/dsl.rb', line 165

def load_from_yaml(file_path, strict: true)
  definition_commands << Qonfig::Commands::Definition::LoadFromYAML.new(
    file_path, strict: strict
  )
end

#predefined_validatorsQonfig::Validation::Collections::PredefinedRegistry

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.



59
60
61
# File 'lib/qonfig/dsl.rb', line 59

def predefined_validators
  @predefined_validators
end

#re_setting(key, initial_value = nil, &nested_settings) ⇒ void

This method returns an undefined value.

Parameters:

  • key (Symbol, String)
  • initial_value (Object) (defaults to: nil)
  • nested_settings (Proc)

See Also:

  • Comamnds::Definition::ReDefineOption

Since:

  • 0.20.0



140
141
142
143
144
# File 'lib/qonfig/dsl.rb', line 140

def re_setting(key, initial_value = nil, &nested_settings)
  definition_commands << Qonfig::Commands::Definition::ReDefineOption.new(
    key, initial_value, nested_settings
  )
end

#setting(key, initial_value = nil, &nested_settings) ⇒ void

This method returns an undefined value.

Parameters:

  • key (Symbol, String)
  • initial_value (Object) (defaults to: nil)
  • nested_settings (Proc)

See Also:

Since:

  • 0.1.0



123
124
125
126
127
128
129
# File 'lib/qonfig/dsl.rb', line 123

def setting(key, initial_value = nil, &nested_settings)
  if block_given?
    definition_commands << Qonfig::Commands::Definition::AddNestedOption.new(key, nested_settings)
  else
    definition_commands << Qonfig::Commands::Definition::AddOption.new(key, initial_value)
  end
end

#validate(setting_key_pattern = nil, predefined = nil, strict: false, by: nil, &custom_validation) ⇒ void

This method returns an undefined value.

Parameters:

  • setting_key_pattern (String, Symbol, NilClass) (defaults to: nil)
  • predefined (String, Symbol) (defaults to: nil)
  • custom_validation (Proc)
  • by (Hash) (defaults to: nil)

    a customizable set of options

  • stict (Hash)

    a customizable set of options

Options Hash (by:):

  • (String, Symbol, NilClass)

See Also:

Since:

  • 0.20.0



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/qonfig/dsl.rb', line 82

def validate(
  setting_key_pattern = nil,
  predefined = nil,
  strict: false,
  by: nil,
  &custom_validation
)
  validators << Qonfig::Validation::Building::InstanceBuilder.build(
    self,
    setting_key_pattern: setting_key_pattern,
    predefined_validator: predefined,
    runtime_validation_method: by,
    strict: strict,
    validation_logic: custom_validation
  )
end

#validatorsQonfig::Validation::Collections::InstanceCollection

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.



67
68
69
# File 'lib/qonfig/dsl.rb', line 67

def validators
  @validators
end

#values_file(file_path, format: :dynamic, strict: false, expose: nil) ⇒ void

This method returns an undefined value.

Parameters:

  • file_path (String, Pathname)
  • format (Hash) (defaults to: :dynamic)

    a customizable set of options

  • strict (Hash) (defaults to: false)

    a customizable set of options

  • expose (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (format:):

  • (String, Symbol)

Options Hash (strict:):

  • (Boolean)

Options Hash (expose:):

  • Environment (NilClass, String, Symbol)

    key

See Also:

Since:

  • 0.17.0



274
275
276
277
278
279
280
# File 'lib/qonfig/dsl.rb', line 274

def values_file(file_path, format: :dynamic, strict: false, expose: nil)
  caller_location = ::Kernel.caller(1, 1).first

  instance_commands << Qonfig::Commands::Instantiation::ValuesFile.new(
    file_path, caller_location, format: format, strict: strict, expose: expose
  )
end