Sha256: 1d0d685040dd89575f9f8f57b5f80b4ef1d4d598d26d03cb8dbf529ec964881c
Contents?: true
Size: 1.31 KB
Versions: 38
Compression:
Stored size: 1.31 KB
Contents
module Appfuel module Config 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 term = term.to_sym 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
38 entries across 38 versions & 1 rubygems