Module: Sequel::Plugins::ModificationDetection

Defined in:
lib/sequel/plugins/modification_detection.rb

Overview

This plugin automatically detects in-place modifications to columns as well as direct modifications of the values hash.

class User < Sequel::Model
  plugin :modification_detection
end
user = User[1]
user.a # => 'a'
user.a << 'b'
user.save_changes
# UPDATE users SET a = 'ab' WHERE (id = 1)

Note that for this plugin to work correctly, the column values must correctly implement the #hash method, returning the same value if the object is equal, and a different value if the object is not equal.

Note that this plugin causes a performance hit for all retrieved objects, so it shouldn’t be used in cases where performance is a primary concern.

Usage:

# Make all model subclass automatically detect column modifications
Sequel::Model.plugin :modification_detection

# Make the Album class automatically detect column modifications
Album.plugin :modification_detection

Defined Under Namespace

Modules: ClassMethods, InstanceMethods