lib/terrestrial/dirty_map.rb in terrestrial-0.1.1 vs lib/terrestrial/dirty_map.rb in terrestrial-0.3.0
- old
+ new
@@ -5,9 +5,14 @@
end
attr_reader :storage
private :storage
+ def load_if_new(record)
+ storage.fetch(hash_key(record)) { self.load(record) }
+ record
+ end
+
def load(record)
storage.store(hash_key(record), deep_clone(record))
record
end