Sha256: 8fb0c9ef17cf383336d7f64dfc8bbed78dd5f1c3f77d9457b9827b998d94933c
Contents?: true
Size: 709 Bytes
Versions: 28
Compression:
Stored size: 709 Bytes
Contents
require_relative './../../external_lib/singleton' require_relative './../../external_lib/securerandom' class ReferencesCache include Singleton def initialize @references_cache = Hash.new end def cache_reference(object_reference) uuid_ = SecureRandom.uuid @references_cache[uuid_] = object_reference uuid_ end def resolve_reference(guid) if @references_cache[guid].nil? raise 'Unable to resolve reference with id: ' + guid.to_s else @references_cache[guid] end end def delete_reference(guid) if @references_cache[guid].nil? raise 'Object not found in reference cache' else @references_cache.delete(guid) 0 end end end
Version data entries
28 entries across 14 versions & 1 rubygems