Class Index [+]

Quicksearch

Sequel::Plugins::OptimisticLocking::InstanceMethods

Public Instance Methods

before_destroy() click to toggle source

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

    # File lib/sequel/plugins/optimistic_locking.rb, line 50
50:         def before_destroy
51:           lock_column_instance_filter
52:           super
53:         end
before_update() click to toggle source

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

    # File lib/sequel/plugins/optimistic_locking.rb, line 56
56:         def before_update
57:           lock_column_instance_filter
58:           super
59:         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).

    # File lib/sequel/plugins/optimistic_locking.rb, line 72
72:         def _refresh(ds)
73:           clear_instance_filters
74:           super
75:         end
_update_columns(columns) click to toggle source

Only update the row if it has the same lock version, and increment the lock version.

    # File lib/sequel/plugins/optimistic_locking.rb, line 79
79:         def _update_columns(columns)
80:           lc = model.lock_column
81:           lcv = send(lc)
82:           columns[lc] = lcv + 1
83:           super
84:           send("#{lc}=", lcv + 1)
85:         end
lock_column_instance_filter() click to toggle source

Add the lock column instance filter to the object.

    # File lib/sequel/plugins/optimistic_locking.rb, line 64
64:         def lock_column_instance_filter
65:           lc = model.lock_column
66:           instance_filter(lc=>send(lc))
67:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.