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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da87610142cd33bf041973b6bbf3d4269b817bfb
4
- data.tar.gz: e950140c0c210c811c4c495222271c0400e3c410
3
+ metadata.gz: 81a6ce132bfed3e01c98e166db83eab36cb957b8
4
+ data.tar.gz: 11ec7fa7d9bdb156273fd0b1d03ff02a2a8cd32d
5
5
  SHA512:
6
- metadata.gz: 529336cecc4d9e93407ecb068cacb7e2c2328beb0c7e9ee88273344b35f0f7a73bea479086735ec0285fca9ceb4153e567bc4fd0eb7c46fa7996a4fe68b56525
7
- data.tar.gz: 68009a7a57bd79a0568b5a9264fe5c0e082b0cd1fcf6fa01561eb7f1b6fe3e042688e6dc61e2cef6546d81c2eea45d0ad802f0d680d264f33a14f625eb59ea0e
6
+ metadata.gz: 4058de2a63288c905d3d3c8f1405b0b9736b510d0e97842849c4a78cc5ac1fe4356a59f9a25daff6e898ddac02036d5703d5ae4cb39bddec28b97c6cb456ea46
7
+ data.tar.gz: f09b0b279301bf701afdd7fb397d51c4bd0aba12a61cacdb2de92aa3d122e68549f0776793562727e41e1bd335dfe668a4388a580b6b4d36db9af2b0e455a0dc
@@ -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).all.each do |t|
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).all.each do |t|
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)
@@ -1,6 +1,6 @@
1
1
  module Mongoid
2
2
  # Mongoid::Tenant::VERSION
3
3
  module Tenant
4
- VERSION = '0.3.1'.freeze
4
+ VERSION = '0.3.3'.freeze
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-tenant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Piccinini