module Sequel::Plugins::Serialization::ClassMethods

  1. lib/sequel/plugins/serialization.rb

Attributes

deserialization_map [R]

A hash with column name symbols and callable values, with the value called to deserialize the column.

serialization_map [R]

A hash with column name symbols and callable values, with the value called to serialize the column.

Public Instance methods

freeze()

Freeze serialization metadata when freezing model class.

[show source]
    # File lib/sequel/plugins/serialization.rb
117 def freeze
118   @deserialization_map.freeze
119   @serialization_map.freeze
120   @serialization_module.freeze if @serialization_module
121 
122   super
123 end
serialize_attributes(format, *columns)

Create instance level reader that deserializes column values on request, and instance level writer that stores new deserialized values.

[show source]
    # File lib/sequel/plugins/serialization.rb
127 def serialize_attributes(format, *columns)
128   if format.is_a?(Symbol)
129     unless format = Sequel.synchronize{REGISTERED_FORMATS[format]}
130       raise(Error, "Unsupported serialization format: #{format} (valid formats: #{Sequel.synchronize{REGISTERED_FORMATS.keys}.inspect})")
131     end
132   end
133   serializer, deserializer = format
134   raise(Error, "No columns given.  The serialization plugin requires you specify which columns to serialize") if columns.empty?
135   define_serialized_attribute_accessor(serializer, deserializer, *columns)
136 end