module Sequel::Plugins::OptimisticLockingBase::InstanceMethods

Public Instance Methods

before_destroy() click to toggle source

Add the lock column instance filter to the object before destroying it.

Calls superclass method
# File lib/sequel/plugins/optimistic_locking_base.rb, line 20
def before_destroy
  lock_column_instance_filter
  super
end
before_update() click to toggle source

Add the lock column instance filter to the object before updating it.

Calls superclass method
# File lib/sequel/plugins/optimistic_locking_base.rb, line 26
def before_update
  lock_column_instance_filter
  super
end

Private Instance Methods

_refresh(ds) click to toggle source

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).

Calls superclass method
# File lib/sequel/plugins/optimistic_locking_base.rb, line 46
def _refresh(ds)
  clear_instance_filters
  super
end
lock_column_instance_filter() click to toggle source

Add the lock column instance filter to the object.

# File lib/sequel/plugins/optimistic_locking_base.rb, line 34
def lock_column_instance_filter
  instance_filter(model.lock_column=>lock_column_instance_filter_value)
end
lock_column_instance_filter_value() click to toggle source

Use the current value of the lock column

# File lib/sequel/plugins/optimistic_locking_base.rb, line 39
def lock_column_instance_filter_value
  public_send(model.lock_column)
end