module Uuidify

Constants

VERSION

Public Class Methods

garbage_collect_uuids() click to toggle source

Clean up all orphaned and useless UUIDs in the database, whether or not we can resolve them to a class.

# File lib/uuidify.rb, line 12
def self.garbage_collect_uuids
  Uuidify::Uuid.select("model_name").group("model_name").each  do |m|
    begin
      klass = m.model_name.constantize
      klass.garbage_collect_uuids
    rescue NameError => ex # Class that doesn't exist in current project
      Uuidify::Uuid.where(:model_name => m.model_name).delete_all
    end
  end
end