module I18n::Backend::Weeler::Dedupe::ClassMethods

Public Instance Methods

dedupe() click to toggle source
# File lib/i18n/backend/weeler/dedupe.rb, line 14
def dedupe
  # find all models and group them on keys which should be common
  grouped = all.group_by{|model| [model.locale,model.key] }
  grouped.values.each do |duplicates|
    # the first one we want to keep right?
    first_one = duplicates.shift # or pop for last one
    # if there are any more left, they are duplicates
    # so delete all of them
    duplicates.each{|double| double.destroy} # duplicates can now be destroyed
  end
end