Does with_lock
lock all models in the block or just the model itself? For example in the following are all the item
models inside with_lock
locked or is just the entry
model locked?
class Entry < ApplicationRecord
enum state: [:pending, :posted]
has_many :items, dependent: :destroy
def post!
with_lock do
return unless pending?
items.each { |i| i.post! }
self.posted!
end
end
end