mongoid-tenant 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mongoid/tenancy.rb +1 -1
- data/lib/mongoid/tenant/tasks/tenant.rake +2 -2
- data/lib/mongoid/tenant/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81a6ce132bfed3e01c98e166db83eab36cb957b8
|
4
|
+
data.tar.gz: 11ec7fa7d9bdb156273fd0b1d03ff02a2a8cd32d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4058de2a63288c905d3d3c8f1405b0b9736b510d0e97842849c4a78cc5ac1fe4356a59f9a25daff6e898ddac02036d5703d5ae4cb39bddec28b97c6cb456ea46
|
7
|
+
data.tar.gz: f09b0b279301bf701afdd7fb397d51c4bd0aba12a61cacdb2de92aa3d122e68549f0776793562727e41e1bd335dfe668a4388a580b6b4d36db9af2b0e455a0dc
|
data/lib/mongoid/tenancy.rb
CHANGED
@@ -16,8 +16,8 @@ module Mongoid
|
|
16
16
|
options[:index] ||= {}
|
17
17
|
|
18
18
|
validates key, { uniqueness: true }.merge(options[:validates])
|
19
|
-
|
20
19
|
index({ key => 1 }, { unique: true }.merge(options[:index]))
|
20
|
+
scope :active_tenants, -> { where(key.ne => nil) }
|
21
21
|
|
22
22
|
define_method(:tenant_key) do
|
23
23
|
send(key).to_s
|
@@ -20,7 +20,7 @@ namespace :db do
|
|
20
20
|
# Run once, for tables outside tenancy
|
21
21
|
::Mongoid::Tasks::Database.create_indexes(non_tenancy_models)
|
22
22
|
if tenancy_env
|
23
|
-
Object.const_get(tenancy_env).
|
23
|
+
Object.const_get(tenancy_env).active_tenants.each do |t|
|
24
24
|
puts "Tenant #{t}"
|
25
25
|
t.tenancy!
|
26
26
|
::Mongoid::Tasks::Database.create_indexes(tenancy_models)
|
@@ -36,7 +36,7 @@ namespace :db do
|
|
36
36
|
# Run once, for tables outside tenancy
|
37
37
|
::Mongoid::Tasks::Database.remove_undefined_indexes(non_tenancy_models)
|
38
38
|
if tenancy_env
|
39
|
-
Object.const_get(tenancy_env).
|
39
|
+
Object.const_get(tenancy_env).active_tenants.each do |t|
|
40
40
|
puts "Tenant #{t}"
|
41
41
|
t.tenancy!
|
42
42
|
::Mongoid::Tasks::Database.remove_undefined_indexes(tenancy_models)
|