Sha256: 3deb883b5082580cad4d5b7b564eddba343cd7b274225cf0f40bab3854c7e86f

Contents?: true

Size: 677 Bytes

Versions: 4

Compression:

Stored size: 677 Bytes

Contents

require 'uuidify/engine'
require 'uuidify/uuidify_concern'

# Helper like acts_as_X so we don't deal with the concern mixin directly.
def uuidify
  include Uuidify::UuidifyConcern
end

module Uuidify
  # Clean up all orphaned and useless UUIDs in the database, whether or not we can
  # resolve them to a class.
  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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
uuidify-0.5.0 lib/uuidify.rb
uuidify-0.4.0 lib/uuidify.rb
uuidify-0.3.1 lib/uuidify.rb
uuidify-0.3.0 lib/uuidify.rb