multi_client 1.1.3 → 2.0.0
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/README.rdoc +31 -0
- data/app/models/concerns/multi_client/model_with_client.rb +7 -2
- data/lib/multi_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e8d6f1bba813f694a3d7cff4c1795f87729eca3
|
4
|
+
data.tar.gz: a9bdd2079350a3117833308a289e6ffde2221a60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24854fc5d4711fb3c868b5a509a28cd520ba863b0aa26d84c6cb6420526efb80ca1f2df7d53751d74a49f1042ec25e5553b69cf2e5db9fde8924168b6d3ec870
|
7
|
+
data.tar.gz: bab0b66dd7d79c78d1092d7c140384409330bf4b872f803c0210e1c1681472afe2e02350a35a8318718fd64b06d4d4a1997592fc0e0eff7d3a3cd6373d0490a6
|
data/README.rdoc
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
= MultiClient
|
2
2
|
|
3
|
+
= Features
|
4
|
+
|
5
|
+
* Blocks calls to unscoped (unless whitelisted)
|
6
|
+
* Gives you a copy of tenant specific classes with the Unscoped suffix, for unscoped access (Post => PostUnscoped).
|
7
|
+
|
3
8
|
= Installation
|
4
9
|
|
5
10
|
Add it to your gemfile:
|
@@ -25,4 +30,30 @@ Add migrations and migrate
|
|
25
30
|
# console
|
26
31
|
MultiClient::Client.unset_current
|
27
32
|
|
33
|
+
|
34
|
+
= Gotchas
|
35
|
+
|
36
|
+
== include MultiClient::ModelWithClient::ActiveSupport::Concern after calls to any class methods.
|
37
|
+
|
38
|
+
If you get errors like Paperclip complaining for missing validators or missing association, please make sure to include MultiClient::ModelWithClient::ActiveSupport::Concern after calls to any class methods
|
39
|
+
|
40
|
+
Wrong:
|
41
|
+
|
42
|
+
class Picture
|
43
|
+
# PictureUnscoped won't pickup the validation
|
44
|
+
include MultiClient::ModelWithClient
|
45
|
+
|
46
|
+
validates_attachment :image, presence: true,
|
47
|
+
content_type: { content_type: /image\/(jpeg|png)/ }
|
48
|
+
end
|
49
|
+
|
50
|
+
Correct:
|
51
|
+
|
52
|
+
class Picture
|
53
|
+
validates_attachment :image, presence: true,
|
54
|
+
content_type: { content_type: /image\/(jpeg|png)/ }
|
55
|
+
|
56
|
+
# Including the module after the class_method call.
|
57
|
+
include MultiClient::ModelWithClient
|
58
|
+
end
|
28
59
|
This project rocks and uses MIT-LICENSE.
|
@@ -10,7 +10,12 @@ module MultiClient
|
|
10
10
|
super
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
namespace = self.name.deconstantize
|
15
|
+
namespace = '::Object' if namespace.empty?
|
16
|
+
klass_name = "#{self.name.demodulize}Unscoped"
|
17
|
+
Rails.logger.info "Defining #{klass_name} on #{namespace}"
|
18
|
+
namespace.constantize.const_set klass_name, klass
|
14
19
|
|
15
20
|
belongs_to MultiClient::Configuration.method_name.to_sym, class_name: MultiClient::Configuration.model_name
|
16
21
|
|
@@ -24,7 +29,7 @@ module MultiClient
|
|
24
29
|
|
25
30
|
class_methods do
|
26
31
|
def unscoped
|
27
|
-
return super if name
|
32
|
+
return super if name =~ /.*Unscoped/
|
28
33
|
caller = caller_locations(1, 1)[0].label
|
29
34
|
return where(MultiClient::Configuration.foreign_key.to_sym => MultiClient::Configuration.model_name.constantize.current_id) if MultiClient::Configuration.force_client_scope_for_unscoped_callers.include?(caller)
|
30
35
|
return super if MultiClient::Configuration.allowed_unscoped_callers.include?(caller)
|
data/lib/multi_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|