Class: EasySettings::EnvSource
- Inherits:
-
PathSource
- Object
- PathSource
- EasySettings::EnvSource
- Defined in:
- lib/easy-settings/env_source.rb
Instance Attribute Summary collapse
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Attributes inherited from PathSource
#base_path, #converter, #parse_values, #separator
Instance Method Summary collapse
-
#initialize(prefix, separator: "__", converter: :downcase, parse_values: true) ⇒ EnvSource
constructor
A new instance of EnvSource.
- #load ⇒ Object
Methods inherited from PathSource
Constructor Details
#initialize(prefix, separator: "__", converter: :downcase, parse_values: true) ⇒ EnvSource
6 7 8 9 |
# File 'lib/easy-settings/env_source.rb', line 6 def initialize(prefix, separator: "__", converter: :downcase, parse_values: true) @prefix = prefix super(nil, separator: separator, converter: converter, parse_values: parse_values) end |
Instance Attribute Details
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
4 5 6 |
# File 'lib/easy-settings/env_source.rb', line 4 def prefix @prefix end |
Instance Method Details
#load ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/easy-settings/env_source.rb', line 11 def load {}.tap do |data| ENV.each do |variable, value| keys = variable.to_s.split(separator) next if prefix.present? && keys.shift != prefix assign_value(data, keys, value) end end end |