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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cb58ce0a29b0c01590346876ed37f738966ae7c
4
- data.tar.gz: 7df066202ff11e2ab9e193258dc2565fedbebbd4
3
+ metadata.gz: 8e8d6f1bba813f694a3d7cff4c1795f87729eca3
4
+ data.tar.gz: a9bdd2079350a3117833308a289e6ffde2221a60
5
5
  SHA512:
6
- metadata.gz: 7b76cf3f0347b7cbbde8d0a8dadf34cec2c7a5972cb313119ddf160eeab656e97180d10a4c522ba6d5742b038f0c69a4dd7c7b44c94483b5a4526601888761de
7
- data.tar.gz: e6d6e187a743603d6e4b4cbddbb3c5521151eb2b2c9d8f2af783caa33cd88701eb5f619a8c3c5804a05094d9fba1730d2891dd2aa10d004fff5905357c552ebd
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
- const_set 'Unscoped', klass
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.demodulize == 'Unscoped'
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)
@@ -1,3 +1,3 @@
1
1
  module MultiClient
2
- VERSION = '1.1.3'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
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: 1.1.3
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-03-21 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails