multi_client 2.0.1 → 2.1.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: 59c04ee2319503a566144f0c9b51dfb6c367be6b
4
- data.tar.gz: 88823dd3e94c27df8390314ff78f8665889c3147
3
+ metadata.gz: 0a1e764f0ea27afe1badcbea40da68d90276fd17
4
+ data.tar.gz: 8c86f38f5c1b50cda437ee573f38b8f0017324bd
5
5
  SHA512:
6
- metadata.gz: f942def3bbd71389636eb77a2fc899a9dd129c1dff86d7315845ff173211138791e5e8a4df7a7b89cb235d860d7d83fc814aa4776d02f7078b25d70863f30ac5
7
- data.tar.gz: e282abdca79c954bfea67afae411cd8449f81515e873256587c207f6e602e9845748bd38ad9d654218221c7425e76d75f2789ee2b891d880b09b2f8599b4e4dd
6
+ metadata.gz: 9ffcb13eab5be661c10bf40a546dcf2c3f1a87f1c1237c3b03f412f4d946553f1a2dffb89da9ffeea2e4e5df681444bc7dc8a68926c325030c09598b997e2761
7
+ data.tar.gz: 401252584ef64dbd75da2ecc42c30ebf663fada4384836ad2aeccea962411aaf00bd5334ebc482904ae9346033d140e6b81c4670a873f7880fed89fb98338a69
data/README.rdoc CHANGED
@@ -30,6 +30,13 @@ Add migrations and migrate
30
30
  # console
31
31
  MultiClient::Client.unset_current
32
32
 
33
+ = How do I execute something in the scope of a Tenant?
34
+
35
+ # console
36
+ Tenant.with_tenant(Tenant.find(1)) do
37
+ # This call will be scoped to tenant_id = 1
38
+ Post.all
39
+ end
33
40
 
34
41
  = Gotchas
35
42
 
@@ -66,4 +73,5 @@ Trying to access this attachment with the regular, scoped version of the model f
66
73
  Solution: This gem adds an interpolation called :class_without_unscoped. Use this interpolation in your url and path paperclip options instead of the origional :class_name.
67
74
 
68
75
  = License
76
+
69
77
  This project rocks and uses MIT-LICENSE.
@@ -31,5 +31,12 @@ module MultiClient
31
31
  def self.unset_current
32
32
  self.current_id = nil
33
33
  end
34
+
35
+ def self.with_tenant(tenant, &block)
36
+ original_id = current_id
37
+ self.current_id = tenant.id
38
+ block.call
39
+ self.current_id = original_id
40
+ end
34
41
  end
35
42
  end
@@ -1,3 +1,3 @@
1
1
  module MultiClient
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.1.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: 2.0.1
4
+ version: 2.1.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-04-01 00:00:00.000000000 Z
11
+ date: 2016-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails