Module: Qonfig::DSL Private

Included in:
DataSet
Defined in:
lib/qonfig/dsl.rb,
lib/qonfig/plugins/toml/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.12.0

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.

Parameters:

Since:

  • 0.1.0



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/qonfig/dsl.rb', line 12

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.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.definition_commands.concat(definition_commands)
      child_klass.instance_commands.concat(instance_commands)
      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::Compose

Since:

  • 0.1.0



70
71
72
# File 'lib/qonfig/dsl.rb', line 70

def compose(data_set_klass)
  definition_commands << Qonfig::Commands::Definition::Compose.new(data_set_klass)
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



33
34
35
# File 'lib/qonfig/dsl.rb', line 33

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)
  • 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)

Since:

  • 0.14.0



150
151
152
153
154
# File 'lib/qonfig/dsl.rb', line 150

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: :yaml) ⇒ void

This method returns an undefined value.

Parameters:

  • env (Hash)

    a customizable set of options

Options Hash (env:):

  • (Symbol, String)

See Also:

  • Commands::LoadFromSelf

Since:

  • 0.14.0



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

def expose_self(env:, format: :yaml)
  caller_location = 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)
  • 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)

Since:

  • 0.12.0



26
27
28
29
30
# File 'lib/qonfig/plugins/toml/dsl.rb', line 26

def expose_toml(file_path, strict: true, via:, env:)
  definition_commands << Qonfig::Commands::ExposeTOML.new(
    file_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)
  • 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)

Since:

  • 0.7.0



136
137
138
139
140
# File 'lib/qonfig/dsl.rb', line 136

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

#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



41
42
43
# File 'lib/qonfig/dsl.rb', line 41

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:

  • Commands::LoadFromENV

Since:

  • 0.2.0



110
111
112
113
114
115
116
# File 'lib/qonfig/dsl.rb', line 110

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)
  • strict (Hash) (defaults to: true)

    a customizable set of options

Options Hash (strict:):

  • (Boolean)

Since:

  • 0.5.0



124
125
126
# File 'lib/qonfig/dsl.rb', line 124

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

#load_from_self(format: :yaml) ⇒ void

This method returns an undefined value.

See Also:

  • Commands::LoadFromSelf

Since:

  • 0.2.0



94
95
96
97
98
99
100
# File 'lib/qonfig/dsl.rb', line 94

def load_from_self(format: :yaml)
  caller_location = 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)
  • strict (Hash) (defaults to: true)

    a customizable set of options

Options Hash (strict:):

  • (Boolean)

Since:

  • 0.12.0



12
13
14
15
16
# File 'lib/qonfig/plugins/toml/dsl.rb', line 12

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

#load_from_yaml(file_path, strict: true) ⇒ void

This method returns an undefined value.

Parameters:

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

    a customizable set of options

Options Hash (strict:):

  • (Boolean)

See Also:

  • Commands::LoadFromYAML

Since:

  • 0.2.0



82
83
84
85
86
# File 'lib/qonfig/dsl.rb', line 82

def load_from_yaml(file_path, strict: true)
  definition_commands << Qonfig::Commands::Definition::LoadFromYAML.new(
    file_path, strict: strict
  )
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:

  • Commands::AddNestedOption
  • Commands::AddOption

Since:

  • 0.1.0



55
56
57
58
59
60
61
# File 'lib/qonfig/dsl.rb', line 55

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

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

This method returns an undefined value.

Parameters:

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

Since:

  • 0.17.0



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

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

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