def apply_custom_fields_diff(name)
      # puts "==> apply_custom_fields_recipes for #{name}, #{self._custom_fields_diff[name].inspect}" # DEBUG

      operations = self._custom_fields_diff[name]
      operations['$set'].merge!({ 'custom_fields_recipe.version' => self.custom_fields_version(name) })
      collection, selector = self.send(name).collection, self.send(name).criteria.selector

      # http://docs.mongodb.org/manual/reference/method/db.collection.update/#update-parameter
      # The <update> document must contain only update operator expressions.
      %w(set unset rename).each do |operation_name|
        _fields = operations.delete("$#{operation_name}")

        next if _fields.empty?

        _operation = { "$#{operation_name}" => _fields }
        collection.find(selector).update_many _operation
      end
    end
def apply_custom_fields_diff(name)
      # puts "==> apply_custom_fields_recipes for #{name}, #{self._custom_fields_diff[name].inspect}" # DEBUG

      operations = self._custom_fields_diff[name]
      operations['$set'].merge!({ 'custom_fields_recipe.version' => self.custom_fields_version(name) })
      collection, selector = self.send(name).collection, self.send(name).criteria.selector

      # http://docs.mongodb.org/manual/reference/method/db.collection.update/#update-parameter
      # The <update> document must contain only update operator expressions.
      %w(set unset rename).each do |operation_name|
        _fields = operations.delete("$#{operation_name}")

        next if _fields.empty?

        _operation = { "$#{operation_name}" => _fields }
        collection.find(selector).update_many _operation
      end
    end
Apply the modifications collected from the custom fields by
 updating all the documents of the relation.
 The update uses the power of mongodb to make it fully optimized.

 @param [ String, Symbol ] name The name of the relation.