Class: SettingsReader::Reader
- Inherits:
-
Object
- Object
- SettingsReader::Reader
show all
- Includes:
- Mixins::Path
- Defined in:
- lib/settings_reader/reader.rb
Overview
Orchestrates fetching values from backend and resolving them
Constant Summary
Mixins::Path::PATH_SEPARATOR
Instance Method Summary
collapse
#decompose_path, #generate_path
Constructor Details
#initialize(base_path, config) ⇒ Reader
Returns a new instance of Reader.
6
7
8
9
10
11
|
# File 'lib/settings_reader/reader.rb', line 6
def initialize(base_path, config)
@base_path = base_path
@config = config
@backends = config.backends
@resolvers = config.resolvers
end
|
Instance Method Details
#blank? ⇒ Boolean
26
27
28
|
# File 'lib/settings_reader/reader.rb', line 26
def blank?
@backends.all? { |backend| backend.get(@base_path).nil? }
end
|
#get(sub_path) ⇒ Object
Also known as:
[]
13
14
15
16
17
|
# File 'lib/settings_reader/reader.rb', line 13
def get(sub_path)
full_path = generate_path(@base_path, sub_path)
value = fetch_value(full_path)
resolve_value(value, full_path)
end
|
#load(sub_path) ⇒ Object
21
22
23
24
|
# File 'lib/settings_reader/reader.rb', line 21
def load(sub_path)
new_path = generate_path(@base_path, sub_path)
SettingsReader::Reader.new(new_path, @config)
end
|
#present? ⇒ Boolean
30
31
32
|
# File 'lib/settings_reader/reader.rb', line 30
def present?
!blank?
end
|