lib/toy/identity_map.rb in toystore-0.6.6 vs lib/toy/identity_map.rb in toystore-0.7.0

- old
+ new

@@ -45,21 +45,20 @@ get_from_identity_map(id) || super end def get_from_identity_map(id) return nil unless identity_map_on? - key = store_key(id) - if record = identity_map[key] - logger.debug("ToyStore IMG #{self.name} #{key.inspect}") + if record = identity_map[id] + log_operation(:img, self.name, store, id) record end end - def load(key, attrs) + def load(id, attrs) return nil if attrs.nil? - if instance = identity_map[store_key(key)] + if instance = identity_map[id] instance else super.tap { |doc| doc.add_to_identity_map } end end @@ -79,19 +78,17 @@ super.tap { remove_from_identity_map } end def add_to_identity_map return unless self.class.identity_map_on? - key = store_key - identity_map[key] = self - logger.debug("ToyStore IMS #{self.class.name} #{key.inspect}") + identity_map[id] = self + log_operation(:ims, self.class.name, store, id) end def remove_from_identity_map return unless self.class.identity_map_on? - key = store_key - identity_map.delete(key) - logger.debug("ToyStore IMD #{self.class.name} #{key.inspect}") + identity_map.delete(id) + log_operation(:imd, self.class.name, store, id) end private def has_embedded_objects? self.class.embedded_lists.any? \ No newline at end of file