Class: EacConfig::EnvvarsNode::Entry
- Defined in:
- lib/eac_config/envvars_node/entry.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from NodeEntry
Class Method Details
.entry_path_to_envvar_name(path) ⇒ Object
13 14 15 16 |
# File 'lib/eac_config/envvars_node/entry.rb', line 13 def entry_path_to_envvar_name(path) ::EacConfig::EntryPath.assert(path).parts.join('_').gsub(/[^a-z0-9_]/i, '') .gsub(/\A_+/, '').gsub(/_+\z/, '').gsub(/_{2,}/, '_').upcase end |
.from_value(string) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/eac_config/envvars_node/entry.rb', line 18 def from_value(string) return nil if string.nil? return ::EacRubyUtils::Yaml.load(string) if string.start_with?('---') string end |
.to_value(object) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/eac_config/envvars_node/entry.rb', line 25 def to_value(object) return nil if object.nil? return object if object.is_a?(String) ::EacRubyUtils::Yaml.dump(object) end |
Instance Method Details
#found? ⇒ Boolean
35 36 37 |
# File 'lib/eac_config/envvars_node/entry.rb', line 35 def found? ENV.key?(envvar_name) end |
#value ⇒ Object
39 40 41 |
# File 'lib/eac_config/envvars_node/entry.rb', line 39 def value self.class.from_value(ENV.fetch(envvar_name, nil)) end |
#value=(a_value) ⇒ Object
43 44 45 |
# File 'lib/eac_config/envvars_node/entry.rb', line 43 def value=(a_value) ENV[envvar_name] = self.class.to_value(a_value) end |