Class: ActiveID::Type::StringUUID

Inherits:
Base
  • Object
show all
Defined in:
lib/active_id/type.rb

Overview

ActiveRecord’s attribute type which serializes UUIDs as strings.

UUIDs are serialized as 36 characters long strings (‘xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`). In PostgreSQL, this representation is compatible with UUID data type, which is a unique feature of this RDBS. In other RDBSes, this attribute type can be used with textual data types (e.g. VARCHAR(36)), however BinaryUUID should be preferred when performance matters.

Instance Attribute Summary

Attributes inherited from Base

#storage_type

Instance Method Summary collapse

Methods inherited from Base

#cast_value, #deserialize, #initialize

Constructor Details

This class inherits a constructor from ActiveID::Type::Base

Instance Method Details

#serialize(value) ⇒ Object



89
90
91
# File 'lib/active_id/type.rb', line 89

def serialize(value)
  s_serialize(cast_to_uuid(value)&.to_s)
end