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.
Class Method Summary collapse
-
.extended(child_klass) ⇒ void
private
rubocop:disable Metrics/LineLength, Metrics/AbcSize.
Instance Method Summary collapse
- #compose(data_set_klass) ⇒ void private
- #define_validator(name, &validation_logic) ⇒ void
- #definition_commands ⇒ Qonfig::CommandSet private
- #expose_json(file_path, strict: true, via:, env:) ⇒ void
- #expose_self(env:, format: :yaml) ⇒ void
- #expose_toml(file_path, strict: true, via:, env:) ⇒ void
- #expose_yaml(file_path, strict: true, via:, env:) ⇒ void
- #freeze_state! ⇒ void
- #instance_commands ⇒ Qonfig::CommandSet private
- #load_from_env(convert_values: false, prefix: nil, trim_prefix: false) ⇒ void
- #load_from_json(file_path, strict: true) ⇒ void
- #load_from_self(format: :yaml) ⇒ void
- #load_from_toml(file_path, strict: true) ⇒ void
- #load_from_yaml(file_path, strict: true) ⇒ void
- #predefined_validators ⇒ Qonfig::Validation::Collections::PredefinedRegistry private
- #re_setting(key, initial_value = nil, &nested_settings) ⇒ void
- #setting(key, initial_value = nil, &nested_settings) ⇒ void
- #validate(setting_key_pattern = nil, predefined = nil, strict: false, by: nil, &custom_validation) ⇒ void
- #validators ⇒ Qonfig::Validation::Collections::InstanceCollection private
- #values_file(file_path, format: :dynamic, strict: false, expose: nil) ⇒ void
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 Metrics/LineLength, Metrics/AbcSize
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/qonfig/dsl.rb', line 17 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::DataSet::ClassBuilder.inherit(base_klass: self, child_klass: 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.
151 152 153 |
# File 'lib/qonfig/dsl.rb', line 151 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.
105 106 107 108 109 |
# File 'lib/qonfig/dsl.rb', line 105 def define_validator(name, &validation_logic) Qonfig::Validation::Building::PredefinedBuilder.build( name, validation_logic, predefined_validators ) end |
#definition_commands ⇒ Qonfig::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.
41 42 43 |
# File 'lib/qonfig/dsl.rb', line 41 def definition_commands @definition_commands end |
#expose_json(file_path, strict: true, via:, env:) ⇒ void
This method returns an undefined value.
237 238 239 240 241 |
# File 'lib/qonfig/dsl.rb', line 237 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.
250 251 252 253 254 255 256 |
# File 'lib/qonfig/dsl.rb', line 250 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.
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_yaml(file_path, strict: true, via:, env:) ⇒ void
This method returns an undefined value.
221 222 223 224 225 |
# File 'lib/qonfig/dsl.rb', line 221 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.
282 283 284 |
# File 'lib/qonfig/dsl.rb', line 282 def freeze_state! instance_commands << Qonfig::Commands::Instantiation::FreezeState.new end |
#instance_commands ⇒ Qonfig::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.
49 50 51 |
# File 'lib/qonfig/dsl.rb', line 49 def instance_commands @instance_commands end |
#load_from_env(convert_values: false, prefix: nil, trim_prefix: false) ⇒ void
This method returns an undefined value.
191 192 193 194 195 196 197 |
# File 'lib/qonfig/dsl.rb', line 191 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.
207 208 209 |
# File 'lib/qonfig/dsl.rb', line 207 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.
175 176 177 178 179 180 181 |
# File 'lib/qonfig/dsl.rb', line 175 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.
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_yaml(file_path, strict: true) ⇒ void
This method returns an undefined value.
163 164 165 166 167 |
# File 'lib/qonfig/dsl.rb', line 163 def load_from_yaml(file_path, strict: true) definition_commands << Qonfig::Commands::Definition::LoadFromYAML.new( file_path, strict: strict ) end |
#predefined_validators ⇒ Qonfig::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.
57 58 59 |
# File 'lib/qonfig/dsl.rb', line 57 def predefined_validators @predefined_validators end |
#re_setting(key, initial_value = nil, &nested_settings) ⇒ void
This method returns an undefined value.
138 139 140 141 142 |
# File 'lib/qonfig/dsl.rb', line 138 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.
121 122 123 124 125 126 127 |
# File 'lib/qonfig/dsl.rb', line 121 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.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/qonfig/dsl.rb', line 80 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 |
#validators ⇒ Qonfig::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.
65 66 67 |
# File 'lib/qonfig/dsl.rb', line 65 def validators @validators end |
#values_file(file_path, format: :dynamic, strict: false, expose: nil) ⇒ void
This method returns an undefined value.
268 269 270 271 272 273 274 |
# File 'lib/qonfig/dsl.rb', line 268 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 |