Class: Qonfig::Commands::LoadFromENV Private
- Defined in:
- lib/qonfig/commands/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(settings) ⇒ void private
-
#initialize(convert_values: false, prefix: nil, trim_prefix: false) ⇒ LoadFromENV
constructor
private
A new instance of LoadFromENV.
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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/qonfig/commands/load_from_env.rb', line 39 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 @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.
12 13 14 |
# File 'lib/qonfig/commands/load_from_env.rb', line 12 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.
18 19 20 |
# File 'lib/qonfig/commands/load_from_env.rb', line 18 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.
30 31 32 |
# File 'lib/qonfig/commands/load_from_env.rb', line 30 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.
24 25 26 |
# File 'lib/qonfig/commands/load_from_env.rb', line 24 def trim_prefix @trim_prefix end |
Instance Method Details
#call(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.
63 64 65 66 67 68 69 |
# File 'lib/qonfig/commands/load_from_env.rb', line 63 def call(settings) env_data = extract_env_data env_based_settings = build_data_set_class(env_data).new.settings settings.__append_settings__(env_based_settings) end |