Class: Qonfig::Commands::Definition::LoadFromENV Private
- Defined in:
- lib/qonfig/commands/definition/load_from_env.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.
Defined Under Namespace
Modules: ValueConverter
Instance Attribute Summary collapse
- #convert_values ⇒ Boolean readonly private
- #prefix_pattern ⇒ Regexp readonly private
- #trim_pattern ⇒ Regexp readonly private
- #trim_prefix ⇒ Boolean readonly private
Instance Method Summary collapse
- #call(data_set, settings) ⇒ void private
-
#initialize(convert_values: false, prefix: nil, trim_prefix: false) ⇒ LoadFromENV
constructor
private
A new instance of LoadFromENV.
Methods inherited from Base
inheritable=, inheritable?, #inheritable?, inherited
Constructor Details
#initialize(convert_values: false, prefix: nil, trim_prefix: false) ⇒ LoadFromENV
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 LoadFromENV.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/qonfig/commands/definition/load_from_env.rb', line 42 def initialize(convert_values: false, prefix: nil, trim_prefix: false) unless convert_values.is_a?(FalseClass) || convert_values.is_a?(TrueClass) raise Qonfig::ArgumentError, ':convert_values option should be a boolean' end unless prefix.is_a?(NilClass) || prefix.is_a?(String) || prefix.is_a?(Regexp) raise Qonfig::ArgumentError, ':prefix option should be a nil / string / regexp' end unless trim_prefix.is_a?(FalseClass) || trim_prefix.is_a?(TrueClass) raise Qonfig::ArgumentError, ':trim_refix options should be a boolean' end @convert_values = convert_values @prefix_pattern = prefix.is_a?(Regexp) ? prefix : /\A#{Regexp.escape(prefix.to_s)}.*\z/m @trim_prefix = trim_prefix # TODO: mb trim_prefix ? @trim_pattern = prefix.is_a?(Regexp) ? prefix : /\A(#{Regexp.escape(prefix.to_s)})/m end |
Instance Attribute Details
#convert_values ⇒ Boolean (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.
15 16 17 |
# File 'lib/qonfig/commands/definition/load_from_env.rb', line 15 def convert_values @convert_values end |
#prefix_pattern ⇒ Regexp (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.
21 22 23 |
# File 'lib/qonfig/commands/definition/load_from_env.rb', line 21 def prefix_pattern @prefix_pattern end |
#trim_pattern ⇒ Regexp (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.
33 34 35 |
# File 'lib/qonfig/commands/definition/load_from_env.rb', line 33 def trim_pattern @trim_pattern end |
#trim_prefix ⇒ Boolean (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.
27 28 29 |
# File 'lib/qonfig/commands/definition/load_from_env.rb', line 27 def trim_prefix @trim_prefix 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.
69 70 71 72 73 |
# File 'lib/qonfig/commands/definition/load_from_env.rb', line 69 def call(data_set, settings) env_data = extract_env_data env_based_settings = build_data_set_klass(env_data).new.settings settings.__append_settings__(env_based_settings) end |