Sha256: 327dfd452fef29d88313c6669a7471dd46f0e4be9ebba0f37851513a84ad5b62
Contents?: true
Size: 1.29 KB
Versions: 7
Compression:
Stored size: 1.29 KB
Contents
module Appfuel module Configuration module Search # Allow you to access child definitions as if it were a hash. # If you add a space separated list of names this will traverse # the child hierarchy and return the last name in the list # # @param name String name or names to search # @return Definition | nil def [](name) find @children, name.to_s.split(" ") end # Allows you to search child definitions using an array of names # instead of a space separated string # # @param names Array of strings # @return Definition | nil def search(*names) return nil if names.empty? find children, names end protected # Recursively locate a child definition in the hierarchy # # @param child_list Hash # @param terms Array of definition keys def find(child_list, terms) while term = terms.shift child_list.each do |(definition_key, definition)| next unless definition_key == term result = if terms.empty? definition else find(definition.children, terms) end return result end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems