Class: ConfigWalkinator
Overview
Ceedling - Test-Centered Build System for C
ThrowTheSwitch.org
Copyright (c) 2010-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
Instance Method Summary collapse
Instance Method Details
#fetch_value(*keys, hash:, default: nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ceedling/config_walkinator.rb', line 10 def fetch_value(*keys, hash:, default:nil) # Safe initial values value = default depth = 0 # Set walk variable walk = hash # Walk into hash & extract value at requested key sequence keys.each { |symbol| # Validate that we can fetch something meaningful if !walk.is_a?( Hash) or !symbol.is_a?( Symbol ) or walk[symbol].nil? value = default break end # Walk into the hash one more level and update value depth += 1 walk = walk[symbol] value = walk } if !walk.nil? return value, depth end |