module ConfigManager class ToggleIdentityMap @thread_map = {} class << self def reset_id_map @thread_map[Thread.current.object_id] = {} end def id_map @thread_map[Thread.current.object_id] ||= {} end def value(key) id_map[key] ||= yield end end end end