Sha256: 7fb74fe40e1b8c1eebadbc6c15e8b9c702d649e1b0bd3d8197847241675a86c9
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
# # Author: Seth Vargo <sethvargo@gmail.com> # # Copyright 2014 Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # module Falcore module Util extend self # # Deeply fech the nested keys, returning +nil+ if an item along the # pathway returns +nil+. # # @param [Hash] hash # the hash to deep fetch # @param [Array] keys # the list of keys to fetch (in order) # def deep_fetch(hash = {}, *keys) keys.inject(hash.dup) do |hash, key| return nil if hash.nil? hash[key] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
falcore-0.2.0 | lib/falcore/util.rb |
falcore-0.1.1 | lib/falcore/util.rb |
falcore-0.1.0 | lib/falcore/util.rb |