Sha256: 249aea05fdfeab42351051487e99f1c510c26fc8e46e58c8a847853a09cd1854
Contents?: true
Size: 746 Bytes
Versions: 17
Compression:
Stored size: 746 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 def fetch(*args) @setup_mock.fetch(*args) 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
17 entries across 17 versions & 1 rubygems