mongoid-multitenancy 1.1.0 → 1.1.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 046b1e5327369856dee33f99a53977a2193dfc78
|
4
|
+
data.tar.gz: 696c53ac82dc8c0580c365379055dcd02bfa64ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf99d6fd58f15a2f12caf85c37a9b621cace5146958c39c34a6df286285dcdbb302664970781f494d6a0761d638a7662cf9a40ccb6413813ccf48002e9238f41
|
7
|
+
data.tar.gz: a8ba34aa544fb199f7f45335224d29e4c3bb90967f0f8240fd0069d0be820c6ae24bb075a5c71aa25a2ba95ab8978386f089b8538076a10435ab0bf5ebe33722
|
@@ -36,8 +36,7 @@ module Mongoid
|
|
36
36
|
criteria = create_criteria(klass, document, attribute, value)
|
37
37
|
|
38
38
|
# <<Add the tenant Criteria>>
|
39
|
-
|
40
|
-
|
39
|
+
criteria = with_tenant_criterion(criteria, klass, document)
|
41
40
|
criteria = criteria.merge(options[:conditions].call) if options[:conditions]
|
42
41
|
|
43
42
|
if Mongoid::VERSION.start_with?('4')
|
@@ -51,18 +50,19 @@ module Mongoid
|
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
54
|
-
#
|
53
|
+
# Add the scope criteria for a tenant model criteria.
|
55
54
|
#
|
56
55
|
# @api private
|
57
|
-
def
|
58
|
-
|
56
|
+
def with_tenant_criterion(criteria, base, document)
|
57
|
+
item = base.tenant_field.to_sym
|
58
|
+
name = document.database_field_name(item)
|
59
59
|
|
60
60
|
if document.class.tenant_options[:optional]
|
61
|
-
if tenant_value
|
62
|
-
criteria.
|
61
|
+
if tenant_value = document.attributes[name]
|
62
|
+
criteria = criteria.where(:"#{item}".in => [tenant_value, nil])
|
63
63
|
end
|
64
64
|
else
|
65
|
-
criteria.
|
65
|
+
criteria = criteria.where(item => tenant_value)
|
66
66
|
end
|
67
67
|
|
68
68
|
criteria
|
data/spec/optional_spec.rb
CHANGED
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aymeric Brisse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
89
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.
|
90
|
+
rubygems_version: 2.2.5
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Support of a multi-tenant database with Mongoid
|