lib/lorj_account.rb in lorj-1.0.7 vs lib/lorj_account.rb in lorj-1.0.8
- old
+ new
@@ -159,11 +159,13 @@
# keys).
# - +default+ : default value, if not found.
# - +options+ : Options for get:
# - +:section+ : Get will use this section name instead of searching it.
# - +:names+ : array of layers name to exclusively get data.
+ # - +:name+ : layer name to exclusively get data.
# - +:indexes+ : array of layers index to exclusively get data.
+ # - +:index+ : layer index to exclusively get data.
# If neither :name or :index is set, get will search
# data on all predefined layers, first found.
# * *Returns* :
# - key value.
# * *Raises* :
@@ -173,13 +175,13 @@
options = {} unless options.is_a?(Hash)
section = options[:section]
section = Lorj.data.first_section(key) if section.nil?
- options = { :keys => [key], :section => section }
+ options = options.merge(:keys => [key], :section => section)
- indexes = _identify_array_indexes(options, exclusive?(key, section))
+ indexes = _identify_indexes(options, exclusive?(key, section))
names = []
indexes.each { |index| names << @config_layers[index][:name] }
options[:data_options] = _set_data_options_per_names(names)
@@ -203,25 +205,27 @@
# - +key+ : key name. It do not support it to be a key tree (Arrays of
# keys).
# - +options+ : possible options:
# - +:section+ : Force to use a specific section name.
# - +:names+ : array of layers name to exclusively get data.
+ # - +:name+ : layer name to exclusively get data.
# - +:indexes+ : array of layers index to exclusively get data.
+ # - +:index+ : layer index to exclusively get data.
# If neither :name or :index is set, get will search data on all
# predefined layers, first found, first listed.
# * *Returns* :
- # - key value.
+ # - config name found.
# * *Raises* :
# Nothing
def where?(key, options = {})
key = key.to_sym if key.class == String
options = {} unless options.is_a?(Hash)
section = options[:section]
- section = Lorj.defaults.get_meta_section(key) if section.nil?
+ section = Lorj.data.first_section(key) if section.nil?
- indexes = _identify_array_indexes(options, exclusive?(key, section))
+ indexes = _identify_indexes(options, exclusive?(key, section))
names = []
indexes.each { |index| names << @config_layers[index][:name] }
where_options = {
@@ -240,32 +244,35 @@
# - +key+ : key name. It do not support it to be a key tree (Arrays of
# keys).
# - +options+ : possible options:
# - +:section+ : Force to use a specific section name.
# - +:names+ : array of layers name to exclusively get data.
+ # - +:name+ : layer name to exclusively get data.
# - +:indexes+ : array of layers index to exclusively get data.
+ # - +:index+ : layer index to exclusively get data.
# If neither :name or :index is set, get will search data on all
# predefined layers, first found.
#
# * *Returns* :
- # - 'runtime' : if found in runtime.
- # - '<AccountName>' : if found in the Account data structure.
- # - 'local' : if found in the local configuration file.
- # Usually ~/.forj/config.yaml
- # - 'default' : if found in the Application default
- # (File 'defaults.yaml') (class Default)
+ # - true : if found in runtime.
+ # - true : if found in the Account data structure.
+ # - true : if found in the local configuration file.
+ # Usually ~/.forj/config.yaml
+ # - true : if found in the Application default
+ # (File 'defaults.yaml') (class Default)
+ # - false otherwise.
# * *Raises* :
# Nothing
def exist?(key, options = nil)
key = key.to_sym if key.class == String
options = {} unless options.is_a?(Hash)
section = options[:section]
section = Lorj.data.first_section(key) if section.nil?
- options = { :keys => [key], :section => section }
+ options = options.merge(:keys => [key], :section => section)
- indexes = _identify_array_indexes(options, exclusive?(key, section))
+ indexes = _identify_indexes(options, exclusive?(key, section))
names = []
indexes.each { |index| names << @config_layers[index][:name] }
options[:data_options] = _set_data_options_per_names(names)
@@ -547,9 +554,11 @@
index = options[:index] if options.key?(:index)
index = layer_index(options[:name]) if options.key?(:name)
indexes = exclusive_indexes(account_exclusive)
indexes = [index] if !index.nil? && indexes.include?(index)
+
+ return _identify_array_indexes(options, account_exclusive) if index.nil?
options[:indexes] = indexes
indexes
end