class ActiveRecord::Type::Uuid::Data

Public Class Methods

from_database(value) click to toggle source
# File lib/active_record-mysql-uuid_column/type_class.rb, line 55
def self.from_database(value)
  return value if value.is_a? Data

  storage_format = value.unpack('H*').first.rjust(32, '0')
  new(
    storage_format.gsub(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, '\1-\2-\3-\4-\5'),
    storage_format
  )
end
from_uuid_string(uuid) click to toggle source
# File lib/active_record-mysql-uuid_column/type_class.rb, line 50
def self.from_uuid_string(uuid)
  return nil if uuid.nil?
  new(uuid, uuid.downcase.gsub(/[^a-f0-9]/, ''))
end
new(display_format, storage_format) click to toggle source
# File lib/active_record-mysql-uuid_column/type_class.rb, line 46
def initialize(display_format, storage_format)
  @display_format, @storage_format = display_format, storage_format
end

Public Instance Methods

==(other) click to toggle source
Calls superclass method
# File lib/active_record-mysql-uuid_column/type_class.rb, line 74
def ==(other)
  other == to_s || super
end
hex() click to toggle source
# File lib/active_record-mysql-uuid_column/type_class.rb, line 70
def hex
  @storage_format
end
to_s() click to toggle source
# File lib/active_record-mysql-uuid_column/type_class.rb, line 65
def to_s
  @display_format
end
Also aliased as: to_str
to_str()
Alias for: to_s