lib/mongoid/locker/wrapper2.rb in mongoid-locker-0.3.6 vs lib/mongoid/locker/wrapper2.rb in mongoid-locker-1.0.0
- old
+ new
@@ -15,12 +15,12 @@
# Determine whether the provided document is locked in the database or not.
#
# @param [Class] The model instance
# @return [Time] The timestamp of when the document is locked until, nil if not locked.
def self.locked_until(doc)
- existing_query = { _id: doc.id, locked_until: { '$exists' => true } }
- existing = doc.class.collection.find_one(existing_query, fields: { locked_until: 1 })
- existing ? existing['locked_until'] : nil
+ existing_query = { _id: doc.id, doc.locked_until_field => { '$exists' => true } }
+ existing = doc.class.collection.find_one(existing_query, fields: { doc.locked_until_field => 1 })
+ existing ? existing[doc.locked_until_field] : nil
end
end
end
end