Class: Etcenv::Environment
- Inherits:
-
Object
- Object
- Etcenv::Environment
- Defined in:
- lib/etcenv/environment.rb
Defined Under Namespace
Classes: DepthLimitError, EtcvaultFailure, KeyNotFound, LoopError, NotDirectory
Constant Summary collapse
- INCLUDE_KEY =
'.include'
- MAX_DEPTH_DEFAULT =
10
Instance Attribute Summary collapse
-
#cluster_index ⇒ Object
readonly
Returns the value of attribute cluster_index.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#etcd ⇒ Object
readonly
Returns the value of attribute etcd.
-
#max_depth ⇒ Object
Returns the value of attribute max_depth.
-
#root_key ⇒ Object
readonly
Returns the value of attribute root_key.
Instance Method Summary collapse
- #expanded_env ⇒ Object
-
#initialize(etcd, root_key, max_depth: MAX_DEPTH_DEFAULT) ⇒ Environment
constructor
A new instance of Environment.
- #keys ⇒ Object
- #load ⇒ Object
- #modified_indices ⇒ Object
Constructor Details
#initialize(etcd, root_key, max_depth: MAX_DEPTH_DEFAULT) ⇒ Environment
Returns a new instance of Environment.
16 17 18 19 20 21 22 |
# File 'lib/etcenv/environment.rb', line 16 def initialize(etcd, root_key, max_depth: MAX_DEPTH_DEFAULT) @etcd = etcd @root_key = root_key @max_depth = max_depth @lock = Mutex.new load end |
Instance Attribute Details
#cluster_index ⇒ Object (readonly)
Returns the value of attribute cluster_index.
24 25 26 |
# File 'lib/etcenv/environment.rb', line 24 def cluster_index @cluster_index end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
24 25 26 |
# File 'lib/etcenv/environment.rb', line 24 def env @env end |
#etcd ⇒ Object (readonly)
Returns the value of attribute etcd.
24 25 26 |
# File 'lib/etcenv/environment.rb', line 24 def etcd @etcd end |
#max_depth ⇒ Object
Returns the value of attribute max_depth.
25 26 27 |
# File 'lib/etcenv/environment.rb', line 25 def max_depth @max_depth end |
#root_key ⇒ Object (readonly)
Returns the value of attribute root_key.
24 25 26 |
# File 'lib/etcenv/environment.rb', line 24 def root_key @root_key end |
Instance Method Details
#expanded_env ⇒ Object
27 28 29 |
# File 'lib/etcenv/environment.rb', line 27 def VariableExpander.(env) end |
#keys ⇒ Object
35 36 37 |
# File 'lib/etcenv/environment.rb', line 35 def keys modified_indices.keys end |
#load ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/etcenv/environment.rb', line 39 def load @lock.synchronize do flush env = {} includes.each do |name| env.merge! fetch(name) end env.delete '.include' @env = env end self end |
#modified_indices ⇒ Object
31 32 33 |
# File 'lib/etcenv/environment.rb', line 31 def modified_indices @modified_indices ||= {} end |