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

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) deserialization_map (readonly)

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



115
116
117
# File 'lib/sequel/plugins/serialization.rb', line 115

def deserialization_map
  @deserialization_map
end

- (Object) serialization_map (readonly)

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



119
120
121
# File 'lib/sequel/plugins/serialization.rb', line 119

def serialization_map
  @serialization_map
end

- (Object) serialization_module

Module to store the serialized column accessor methods, so they can call be overridden and call super to get the serialization behavior



123
124
125
# File 'lib/sequel/plugins/serialization.rb', line 123

def serialization_module
  @serialization_module
end

Instance Method Details

- (Object) serialize_attributes(format, *columns)

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

Raises:



129
130
131
132
133
134
135
136
137
138
# File 'lib/sequel/plugins/serialization.rb', line 129

def serialize_attributes(format, *columns)
  if format.is_a?(Symbol)
    unless format = REGISTERED_FORMATS[format]
      raise(Error, "Unsupported serialization format: #{format} (valid formats: #{REGISTERED_FORMATS.keys.map{|k| k.inspect}.join})")
    end
  end
  serializer, deserializer = format
  raise(Error, "No columns given.  The serialization plugin requires you specify which columns to serialize") if columns.empty?
  define_serialized_attribute_accessor(serializer, deserializer, *columns)
end

- (Object) serialized_columns

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



142
143
144
# File 'lib/sequel/plugins/serialization.rb', line 142

def serialized_columns
  serialization_map.keys
end