Sha256: b43b8332367470e79dd13fbf1b6d8effd1520518b820a8a79821717e042ca52c
Contents?: true
Size: 765 Bytes
Versions: 4
Compression:
Stored size: 765 Bytes
Contents
module RubyPitaya class ConfigSpecHelper def initialize @config_mock = {} end def [](key) split_key = key.split('.') @config_mock.dig(*split_key) end def auto_reload end def config_mock=(value) @config_mock = value end def config_core_override=(value) @config_mock = value end def add(key, value) keys = key.split('.') add_hash = undig(*keys, value) @config_mock = merge_recursively(@config_mock, add_hash) end private def undig(*keys, value) keys.empty? ? value : { keys.first=>undig(*keys.drop(1), value) } end def merge_recursively(a, b) a.merge(b) {|key, a_item, b_item| merge_recursively(a_item, b_item) } end end end
Version data entries
4 entries across 4 versions & 1 rubygems