Module: T::Types::TypedClass::Private::Pool
- Defined in:
- lib/types/types/typed_class.rb
Constant Summary collapse
- CACHE_FROZEN_OBJECTS =
begin ObjectSpace::WeakMap.new[1] = 1 true # Ruby 2.7 and newer rescue ArgumentError false # Ruby 2.6 and older end
Class Method Summary collapse
Class Method Details
.type_for_module(mod) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/types/types/typed_class.rb', line 58 def self.type_for_module(mod) cached = @cache[mod] return cached if cached type = TypedClass.new(mod) if CACHE_FROZEN_OBJECTS || (!mod.frozen? && !type.frozen?) @cache[mod] = type end type end |