module Sequel::Plugins::PgXminOptimisticLocking
By default, the plugin allows using the xmin= setter method to either increase or decrease the lock value. To prevent increases, which could potentially be used to skip an update when it update should be made, you can use the :prevent_increase plugin argument:
plugin :pg_xmin_optimistic_locking, prevent_increase: true
This plugin may not work with the class_table_inheritance plugin.
This plugin relies on the instance_filters plugin.
Constants
- WILDCARD
Public Class Methods
apply(model, prevent_increase: false)
click to toggle source
Define the xmin column accessor
# File lib/sequel/plugins/pg_xmin_optimistic_locking.rb 39 def self.apply(model, prevent_increase: false) 40 model.instance_exec do 41 plugin(:optimistic_locking_base) 42 @lock_column = :xmin 43 def_column_accessor(:xmin) 44 end 45 end
configure(model, prevent_increase: false)
click to toggle source
Update the dataset to append the xmin column if it is usable and there is a dataset for the model.
# File lib/sequel/plugins/pg_xmin_optimistic_locking.rb 49 def self.configure(model, prevent_increase: false) 50 model.instance_exec do 51 set_dataset(@dataset) if @dataset 52 # SEQUEL6: Make prevent_increase true by default 53 prevent_lock_column_increase! if prevent_increase 54 end 55 end