Module: Sequel::Plugins::Serialization::ClassMethods
- Defined in:
- lib/sequel/plugins/serialization.rb
Instance Attribute Summary collapse
-
#deserialization_map ⇒ Object
readonly
A hash with column name symbols and callable values, with the value called to deserialize the column.
-
#serialization_map ⇒ Object
readonly
A hash with column name symbols and callable values, with the value called to serialize the column.
-
#serialization_module ⇒ Object
Module to store the serialized column accessor methods, so they can call be overridden and call super to get the serialization behavior.
Instance Method Summary collapse
-
#serialize_attributes(format, *columns) ⇒ Object
Create instance level reader that deserializes column values on request, and instance level writer that stores new deserialized values.
-
#serialized_columns ⇒ Object
The columns that will be serialized.
Instance Attribute Details
#deserialization_map ⇒ Object (readonly)
A hash with column name symbols and callable values, with the value called to deserialize the column.
117 118 119 |
# File 'lib/sequel/plugins/serialization.rb', line 117 def deserialization_map @deserialization_map end |
#serialization_map ⇒ Object (readonly)
A hash with column name symbols and callable values, with the value called to serialize the column.
121 122 123 |
# File 'lib/sequel/plugins/serialization.rb', line 121 def serialization_map @serialization_map end |
#serialization_module ⇒ Object
Module to store the serialized column accessor methods, so they can call be overridden and call super to get the serialization behavior
125 126 127 |
# File 'lib/sequel/plugins/serialization.rb', line 125 def serialization_module @serialization_module end |
Instance Method Details
#serialize_attributes(format, *columns) ⇒ Object
Create instance level reader that deserializes column values on request, and instance level writer that stores new deserialized values.
131 132 133 134 135 136 137 138 139 140 |
# File 'lib/sequel/plugins/serialization.rb', line 131 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(&: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 |
#serialized_columns ⇒ Object
The columns that will be serialized. This is only for backwards compatibility, use serialization_map in new code.
144 145 146 |
# File 'lib/sequel/plugins/serialization.rb', line 144 def serialized_columns serialization_map.keys end |