Sha256: da9be1341f747286efffb63150588c5616668fb9bb30fb38897975020845ac7d

Contents?: true

Size: 755 Bytes

Versions: 6

Compression:

Stored size: 755 Bytes

Contents

$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
require_relative './sample_app'
require 'pp'

MarkMapper.application.create

MarkMapper::Plugins::IdentityMap.enabled = true

class User
  include MarkMapper::Document

  key :name, String
end
User.delete_all

# User gets added to map on save
user = User.create(:name => 'John')

# Does not matter how you find user, it is always the same object until the identity map is cleared
puts "#{User.find(user.id).object_id} == #{user.object_id}"
puts "#{User.all[0].object_id} == #{user.object_id}"

MarkMapper::Plugins::IdentityMap.clear
puts "#{User.find(user.id).object_id} != #{user.object_id}"

# User gets removed from map on destroy
user = User.create
user.destroy

MarkMapper.application.drop

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mark_mapper-0.0.6 examples/identity_map.rb
mark_mapper-0.0.5 examples/identity_map.rb
mark_mapper-0.0.4 examples/identity_map.rb
mark_mapper-0.0.3 examples/identity_map.rb
mark_mapper-0.0.2 examples/identity_map.rb
mark_mapper-0.0.1 examples/identity_map.rb