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
# File 'lib/qonfig/dsl.rb', line 12

def extended(child_klass)
  child_klass.instance_variable_set(:@commands, Qonfig::CommandSet.new)

  child_klass.singleton_class.prepend(Module.new do
    def inherited(child_klass)
      child_klass.instance_variable_set(:@commands, Qonfig::CommandSet.new)
      child_klass.commands.concat(commands)
      super
    end
  end)
end

Instance Method Details

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



29
30
31
# File 'lib/qonfig/dsl.rb', line 29

def commands
  @commands
end

#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



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

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



131
132
133
# File 'lib/qonfig/dsl.rb', line 131

def expose_json(file_path, strict: true, via:, env:)
  commands << Qonfig::Commands::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:

Since:

  • 0.14.0



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

def expose_self(env:, format: :yaml)
  caller_location = caller(1, 1).first
  commands << Qonfig::Commands::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



24
25
26
# File 'lib/qonfig/plugins/toml/dsl.rb', line 24

def expose_toml(file_path, strict: true, via:, env:)
  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



119
120
121
# File 'lib/qonfig/dsl.rb', line 119

def expose_yaml(file_path, strict: true, via:, env:)
  commands << Qonfig::Commands::ExposeYAML.new(file_path, strict: strict, via: via, env: env)
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



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

def load_from_env(convert_values: false, prefix: nil, trim_prefix: false)
  commands << Qonfig::Commands::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



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

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

#load_from_self(format: :yaml) ⇒ void

This method returns an undefined value.

See Also:

Since:

  • 0.2.0



80
81
82
83
# File 'lib/qonfig/dsl.rb', line 80

def load_from_self(format: :yaml)
  caller_location = caller(1, 1).first
  commands << Qonfig::Commands::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
# File 'lib/qonfig/plugins/toml/dsl.rb', line 12

def load_from_toml(file_path, strict: true)
  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:

Since:

  • 0.2.0



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

def load_from_yaml(file_path, strict: true)
  commands << Qonfig::Commands::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:

Since:

  • 0.1.0



43
44
45
46
47
48
49
# File 'lib/qonfig/dsl.rb', line 43

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