Module: Sequel::Plugins::Serialization::ClassMethods

Module | Sequel::Plugins::Serialization::ClassMethods
In: | lib/sequel/plugins/serialization.rb

### Methods

inherited serialization_format serialize_attributes serialized_columns

### Attributes

serialization_map | [R] | A map of the serialized columns for this model. Keys are column symbols, values are serialization formats (:marshal, :yaml, or :json).
serialization_module | [RW] | Module to store the serialized column accessor methods, so they can call be overridden and call super to get the serialization behavior

### Public Instance methods

inherited(subclass)

Copy the serialization format and columns to serialize into the subclass.

[Source]

        # File lib/sequel/plugins/serialization.rb, line 56
    56:         def inherited(subclass)
    57:           super
    58:           sm = serialization_map.dup
    59:           subclass.instance_eval{@serialization_map = sm}
    60:         end

serialization_format()

The first value in the serialization map. This is only for backwards compatibility, use serialization_map in new code.

[Source]

        # File lib/sequel/plugins/serialization.rb, line 64
    64:         def serialization_format
    65:           serialization_map.values.first
    66:         end

serialize_attributes(format, *columns)

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

[Source]

        # File lib/sequel/plugins/serialization.rb, line 71
    71:         def serialize_attributes(format, *columns)
    72:           raise(Error, "Unsupported serialization format (#{format}), should be :marshal, :yaml, or :json") unless [:marshal, :yaml, :json].include?(format)
    73:           raise(Error, "No columns given.  The serialization plugin requires you specify which columns to serialize") if columns.empty?
    74:           define_serialized_attribute_accessor(format, *columns)
    75:         end

serialized_columns()

The columns that will be serialized. This is only for backwards compatibility, use serialization_map in new code.

[Source]

        # File lib/sequel/plugins/serialization.rb, line 79
    79:         def serialized_columns
    80:           serialization_map.keys
    81:         end

[Validate]