Add the lock column instance filter to the object before destroying it.
# File lib/sequel/plugins/optimistic_locking.rb, line 44 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 50 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 66 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 73 def _update_columns(columns) lc = model.lock_column lcv = get_column_value(lc) columns[lc] = lcv + 1 super set_column_value("#{lc}=", lcv + 1) end
Add the lock column instance filter to the object.
# File lib/sequel/plugins/optimistic_locking.rb, line 58 def lock_column_instance_filter lc = model.lock_column instance_filter(lc=>get_column_value(lc)) end