Class: SpaceCadetWrapper

Inherits:
Object
  • Object
show all
Includes:
SpaceCadetUuid
Defined in:
lib/space_cadet.rb

Constant Summary collapse

ID_BIT_COUNT =
31

Constants included from SpaceCadetActiveRecordUuid

SpaceCadetActiveRecordUuid::ID_RETRY_COUNT

Instance Method Summary collapse

Methods included from SpaceCadetActiveRecordUuid

#add_uuid, #space_id_add_uuid, #uuid_create

Methods included from SpaceCadetSpaceId

#high_order_bits_from_hex_string, #low_order_bits_from_hex_string, #num_from_hex_string, #space_id_from_uuid

Instance Method Details

#after_create(record) ⇒ Object



9
10
11
12
13
# File 'lib/space_cadet.rb', line 9

def after_create record
  source_id = record.id
  source_name = record.class.table_name
  uuid_create SpaceCadet::Uuid, source_id, source_name, ID_BIT_COUNT
end

#before_destroy(record) ⇒ Object



15
16
17
18
19
# File 'lib/space_cadet.rb', line 15

def before_destroy record
  u = SpaceCadet::Uuid.find_by_source_name_and_source_id(
      record.class.table_name, record.id)
  SpaceCadet::Uuid.delete u.id
end