module Uuidify::UuidifyConcern::ClassMethods

Public Instance Methods

garbage_collect_uuids() click to toggle source

Delete entries where we don't have a model that can be instantiated anymore.

# File lib/uuidify/uuidify_concern.rb, line 29
def garbage_collect_uuids
  Uuidify::Uuid.where(:model_name => self.to_s).find_each do |uuid|
    if !where(:id => uuid.model_id).first
      uuid.destroy
    end
  end
end
lookup_uuid(uuid) click to toggle source

.find_by_uuid. Used lookup so we know it's not rails magic.

# File lib/uuidify/uuidify_concern.rb, line 21
def lookup_uuid(uuid)
  uuid = Uuidify::Uuid.uuid_to_sql_string(uuid)
  
  uuid = Uuidify::Uuid.where(:model_uuid => uuid, :model_name => self.to_s).first
  uuid ? find(uuid.model_id) : nil
end