mongomatic 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mongomatic/base.rb +5 -1
- metadata +2 -2
data/lib/mongomatic/base.rb
CHANGED
@@ -312,7 +312,11 @@ module Mongomatic
|
|
312
312
|
|
313
313
|
def transaction(key=nil, duration=5, &block)
|
314
314
|
raise Mongomatic::Exceptions::DocumentIsNew if new?
|
315
|
-
key
|
315
|
+
if key.is_a?(Hash) && key[:scope]
|
316
|
+
key = [self.class.name, self["_id"].to_s, key[:scope]].join("-")
|
317
|
+
else
|
318
|
+
key ||= [self.class.name, self["_id"].to_s].join("-")
|
319
|
+
end
|
316
320
|
TransactionLock.start(key, duration, &block)
|
317
321
|
end
|
318
322
|
end
|