lib/fixtury/locator_backend/memory.rb in fixtury-1.0.0.beta1 vs lib/fixtury/locator_backend/memory.rb in fixtury-1.0.0.beta2
- old
+ new
@@ -6,11 +6,11 @@
module LocatorBackend
class Memory
include ::Fixtury::LocatorBackend::Common
- MATCHER = /^fixtury-oid-(?<object_id>[\d]+)$/.freeze
+ MATCHER = /^fixtury-oid-(?<process_id>[\d]+)-(?<object_id>[\d]+)$/.freeze
def recognizable_key?(locator_value)
locator_value.is_a?(String) && MATCHER.match?(locator_value)
end
@@ -19,17 +19,18 @@
end
def load_reference(locator_value)
match = MATCHER.match(locator_value)
return nil unless match
+ return nil unless match[:process_id].to_i == Process.pid
::ObjectSpace._id2ref(match[:object_id].to_i)
rescue RangeError
nil
end
def dump_value(stored_value)
- "fixtury-oid-#{stored_value.object_id}"
+ "fixtury-oid-#{Process.pid}-#{stored_value.object_id}"
end
end
end
end