Module: Sequel::Plugins::SerializationModificationDetection
- Defined in:
- lib/sequel/plugins/serialization_modification_detection.rb
Overview
Sequel’s built in Serialization plugin doesn’t check for modification of the serialized objects, because it requires an extra deserialization of a potentially very large object. This plugin can detect changes in serialized values by checking whether the current deserialized value is the same as the original deserialized value. This does require deserializing the value twice, but the original deserialized value is cached.
Example
require 'sequel'
require 'json'
class User < Sequel::Model
plugin :serialization, :json, :permissions
plugin :serialization_modification_detection
end
user = User.create(:permissions => {})
user.[:global] = 'read-only'
user.save_changes
Defined Under Namespace
Modules: InstanceMethods
Class Method Summary collapse
-
.apply(model) ⇒ Object
Load the serialization plugin automatically.
Class Method Details
.apply(model) ⇒ Object
Load the serialization plugin automatically.
23 24 25 |
# File 'lib/sequel/plugins/serialization_modification_detection.rb', line 23 def self.apply(model) model.plugin :serialization end |