Sha256: c520fa7a5326ddabafb124ca55847a75b1bb80a909ef26327b6abecb8572635c

Contents?: true

Size: 741 Bytes

Versions: 28

Compression:

Stored size: 741 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

Version Path
javonet-ruby-sdk-2.5.7 lib/javonet-ruby-sdk/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.7 lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.6 lib/javonet-ruby-sdk/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.6 lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.5 lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.5 lib/javonet-ruby-sdk/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.4 lib/javonet-ruby-sdk/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.4 lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.3 lib/javonet-ruby-sdk/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.3 lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.2 lib/javonet-ruby-sdk/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.2 lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.1 lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.1 lib/javonet-ruby-sdk/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.0 lib/javonet-ruby-sdk/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.5.0 lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.4.11 lib/javonet-ruby-sdk/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.4.11 lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/reference_cache/references_cache.rb
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/core/reference_cache/references_cache.rb