diff --git a/lib/resolv.rb b/lib/resolv.rb index 1653619..59ec3dc 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -2107,7 +2107,14 @@ class Resource < Query attr_reader :ttl - ClassHash = {} # :nodoc: + ClassHash = Module.new do + module_function + + def []=(type_class_value, klass) + type_value, class_value = type_class_value + Resource.const_set(:"Type#{type_value}_Class#{class_value}", klass) + end + end def encode_rdata(msg) # :nodoc: raise NotImplementedError.new @@ -2145,7 +2152,9 @@ def hash # :nodoc: end def self.get_class(type_value, class_value) # :nodoc: - return ClassHash[[type_value, class_value]] || + cache = :"Type#{type_value}_Class#{class_value}" + + return (const_defined?(cache) && const_get(cache)) || Generic.create(type_value, class_value) end