Sha256: ff87f037ae5794967252199292694e85045d0bc082622bc4c6e33662c10ea8bf
Contents?: true
Size: 685 Bytes
Versions: 29
Compression:
Stored size: 685 Bytes
Contents
module RubyPitaya class SetupSpecHelper def initialize @setup_mock = {} end def [](key) split_key = key.split('.') @setup_mock.dig(*split_key) end def auto_reload end def setup_mock=(value) @setup_mock = value end def add(key, value) keys = key.split('.') add_hash = undig(*keys, value) @setup_mock = merge_recursively(@setup_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
29 entries across 29 versions & 1 rubygems