Sha256: 22534dc8b20cb924f24d8c0d09ac5ec494d613ae36955642535cceabb90bc317

Contents?: true

Size: 415 Bytes

Versions: 4

Compression:

Stored size: 415 Bytes

Contents

class Sfn::IdentityMap
  attr_reader :records, :pages
  
  def initialize
    @records = {}
    @pages = {}
  end
  
  def get_record(klass, id, path='', &block)
    result = @records[[klass, id, path]]
    result ||= begin
      obj = yield(klass, id, path)
      @records[[klass, id, path]] = obj
    end
    result
  end
  
  def expire_record(klass, id, path='')
    @records[[klass, id, path]] = nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-satisfaction-0.7.5 lib/satisfaction/identity_map.rb
ruby-satisfaction-0.7.4 lib/satisfaction/identity_map.rb
ruby-satisfaction-0.7.3 lib/satisfaction/identity_map.rb
ruby-satisfaction-0.7.0 lib/satisfaction/identity_map.rb