Class: Anyway::Env
Overview
Parses environment variables and provides method-like access
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#traces ⇒ Object
readonly
Returns the value of attribute traces.
-
#type_cast ⇒ Object
readonly
Returns the value of attribute type_cast.
Instance Method Summary collapse
- #clear ⇒ Object
- #fetch(prefix) ⇒ Object
- #fetch_with_trace(prefix) ⇒ Object
-
#initialize(type_cast: AutoCast) ⇒ Env
constructor
A new instance of Env.
Methods included from Tracing
capture, current_trace, current_trace_source, source_stack, trace!, trace_stack, with_trace_source
Constructor Details
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
13 14 15 |
# File 'lib/anyway/env.rb', line 13 def data @data end |
#traces ⇒ Object (readonly)
Returns the value of attribute traces.
13 14 15 |
# File 'lib/anyway/env.rb', line 13 def traces @traces end |
#type_cast ⇒ Object (readonly)
Returns the value of attribute type_cast.
13 14 15 |
# File 'lib/anyway/env.rb', line 13 def type_cast @type_cast end |
Instance Method Details
#clear ⇒ Object
21 22 23 24 |
# File 'lib/anyway/env.rb', line 21 def clear data.clear traces.clear end |
#fetch(prefix) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/anyway/env.rb', line 26 def fetch(prefix) return data[prefix].deep_dup if data.key?(prefix) Tracing.capture do data[prefix] = parse_env(prefix) end.then do |trace| traces[prefix] = trace end data[prefix].deep_dup end |
#fetch_with_trace(prefix) ⇒ Object
38 39 40 |
# File 'lib/anyway/env.rb', line 38 def fetch_with_trace(prefix) [fetch(prefix), traces[prefix]] end |