mongoid-multitenancy 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/Gemfile +1 -0
- data/gemfiles/Gemfile.mongoid-4.0 +1 -0
- data/gemfiles/Gemfile.mongoid-5.0 +1 -0
- data/lib/mongoid/multitenancy/document.rb +1 -1
- data/lib/mongoid/multitenancy/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +2 -4
- data/spec/support/database_cleaner.rb +0 -36
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 30fa52034535ce4524481877d5b9e048e1eeeaa5
|
|
4
|
+
data.tar.gz: 533f4f95ecb750443629027cac6d0dd9edc6bb73
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: efb3239aa595fe974954364f1b8b7cf2b0bb061d87dac50166294f54a219ed97b68504deead534086576016e840d38b125612a64d12a429d3b37c19ef90deb6a
|
|
7
|
+
data.tar.gz: f3a64574e2ef09ade685ab061806bd37885286ead3efe20d884887d14e42ab748e712a1635b9fc2724aa6bb520d614684e70b973bf4952b2866bad396e2125fd
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -120,7 +120,7 @@ module Mongoid
|
|
|
120
120
|
def define_initializer(association)
|
|
121
121
|
# Apply the default value when the default scope is complex (optional tenant)
|
|
122
122
|
after_initialize lambda {
|
|
123
|
-
if Multitenancy.current_tenant &&
|
|
123
|
+
if Multitenancy.current_tenant && new_record?
|
|
124
124
|
send "#{association}=".to_sym, Multitenancy.current_tenant
|
|
125
125
|
end
|
|
126
126
|
}
|
data/spec/spec_helper.rb
CHANGED
|
@@ -2,6 +2,7 @@ MODELS = File.join(File.dirname(__FILE__), 'models')
|
|
|
2
2
|
|
|
3
3
|
require 'simplecov'
|
|
4
4
|
require 'coveralls'
|
|
5
|
+
require 'database_cleaner'
|
|
5
6
|
|
|
6
7
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
|
7
8
|
SimpleCov::Formatter::HTMLFormatter,
|
|
@@ -21,7 +22,6 @@ elsif Mongoid::VERSION.start_with? '4'
|
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
require_relative 'support/shared_examples'
|
|
24
|
-
require_relative 'support/database_cleaner'
|
|
25
25
|
require_relative 'support/mongoid_matchers'
|
|
26
26
|
|
|
27
27
|
Dir["#{MODELS}/*.rb"].each { |f| require f }
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongoid-multitenancy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aymeric Brisse
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mongoid
|
|
@@ -64,7 +64,6 @@ files:
|
|
|
64
64
|
- spec/mutable_spec.rb
|
|
65
65
|
- spec/optional_spec.rb
|
|
66
66
|
- spec/spec_helper.rb
|
|
67
|
-
- spec/support/database_cleaner.rb
|
|
68
67
|
- spec/support/mongoid_matchers.rb
|
|
69
68
|
- spec/support/shared_examples.rb
|
|
70
69
|
homepage: https://github.com/PerfectMemory/mongoid-multitenancy
|
|
@@ -108,7 +107,6 @@ test_files:
|
|
|
108
107
|
- spec/mutable_spec.rb
|
|
109
108
|
- spec/optional_spec.rb
|
|
110
109
|
- spec/spec_helper.rb
|
|
111
|
-
- spec/support/database_cleaner.rb
|
|
112
110
|
- spec/support/mongoid_matchers.rb
|
|
113
111
|
- spec/support/shared_examples.rb
|
|
114
112
|
has_rdoc:
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
class DatabaseCleaner
|
|
2
|
-
class << self
|
|
3
|
-
def clean
|
|
4
|
-
new.clean
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def clean
|
|
9
|
-
if mongoid4?
|
|
10
|
-
collections.each { |c| database[c].find.remove_all }
|
|
11
|
-
else
|
|
12
|
-
collections.each { |c| database[c].find.delete_many }
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
def mongoid4?
|
|
19
|
-
Mongoid::VERSION.start_with? '4'
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def database
|
|
23
|
-
if mongoid4?
|
|
24
|
-
Mongoid.default_session
|
|
25
|
-
else
|
|
26
|
-
Mongoid::Clients.default
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def collections
|
|
31
|
-
database['system.namespaces'].find(name: { '$not' => /\.system\.|\$/ }).to_a.map do |collection|
|
|
32
|
-
_, name = collection['name'].split('.', 2)
|
|
33
|
-
name
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|