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

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