class TinyStruct::ObjectSpaceCache

Allows for finding previously constructed `TinyStruct` classes that contain a certain set of members so that they do not end up getting created twice.

This cache saves some on space because we're not storing them in memory, but takes a slight hit to performance whenever a new class in defined.

Public Instance Methods

[](members) click to toggle source
# File lib/tiny_struct/object_space_cache.rb, line 10
def [](members)
  ObjectSpace.each_object(TinyStruct.singleton_class).detect do |clazz|
    clazz != TinyStruct && clazz.members == members
  end
end
[]=(*) click to toggle source
# File lib/tiny_struct/object_space_cache.rb, line 8
def []=(*); end