Add the lock column instance filter to the object before destroying it.
# File lib/sequel/plugins/optimistic_locking.rb, line 46 def before_destroy lock_column_instance_filter super end
Add the lock column instance filter to the object before updating it.
# File lib/sequel/plugins/optimistic_locking.rb, line 52 def before_update lock_column_instance_filter super end
Clear the instance filters when refreshing, so that attempting to refresh after a failed save removes the previous lock column filter (the new one will be added before updating).
# File lib/sequel/plugins/optimistic_locking.rb, line 68 def _refresh(ds) clear_instance_filters super end
Only update the row if it has the same lock version, and increment the lock version.
# File lib/sequel/plugins/optimistic_locking.rb, line 75 def _update_columns(columns) lc = model.lock_column lcv = send(lc) columns[lc] = lcv + 1 super send("#{lc}=", lcv + 1) end
Add the lock column instance filter to the object.
# File lib/sequel/plugins/optimistic_locking.rb, line 60 def lock_column_instance_filter lc = model.lock_column instance_filter(lc=>send(lc)) end