lib/mongoid/tenant/tasks/tenant.rake in mongoid-tenant-0.0.5 vs lib/mongoid/tenant/tasks/tenant.rake in mongoid-tenant-0.0.7
- old
+ new
@@ -1,26 +1,27 @@
-Rake::Task["db:mongoid:create_indexes"].clear
-Rake::Task["db:mongoid:remove_undefined_indexes"].clear
+Rake::Task['db:mongoid:create_indexes'].clear
+Rake::Task['db:mongoid:remove_undefined_indexes'].clear
namespace :db do
namespace :mongoid do
-
- def get_tenancy
+ def tenancy_env
ENV['TENANCY'] ||
fail("Provide a tenancy model: `TENANCY=Foo #{ARGV.join}`")
end
- task :create_indexes => [:environment, :load_models] do
- Rake::Task["db:mongoid:create_indexes"].clear
- Object.const_get(get_tenancy).all.each do |t|
+ desc 'Create Mongoid indexes, tenant aware'
+ task create_indexes: [:environment, :load_models] do
+ Rake::Task['db:mongoid:create_indexes'].clear
+ Object.const_get(tenancy_env).all.each do |t|
puts "Tenant #{t}"
t.tenancy!
::Mongoid::Tasks::Database.create_indexes
end
end
- task :remove_undefined_indexes => [:environment, :load_models] do
- Object.const_get(get_tenancy).all.each do |t|
+ desc 'Removes undefined Mongoid indexes, tenant aware'
+ task remove_undefined_indexes: [:environment, :load_models] do
+ Object.const_get(tenancy_env).all.each do |t|
puts "Tenant #{t}"
t.tenancy!
::Mongoid::Tasks::Database.remove_undefined_indexes
end
end