lib/mongoid/locker/wrapper5.rb in mongoid-locker-0.3.6 vs lib/mongoid/locker/wrapper5.rb in mongoid-locker-1.0.0

- old
+ new

@@ -16,12 +16,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.where(existing_query).limit(1).only(:locked_until).first - existing ? existing.locked_until : nil + existing_query = { _id: doc.id, doc.locked_until_field => { '$exists' => true } } + existing = doc.class.where(existing_query).limit(1).only(doc.locked_until_field).first + existing ? existing[doc.locked_until_field] : nil end end end end