multi_client 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a1e764f0ea27afe1badcbea40da68d90276fd17
4
- data.tar.gz: 8c86f38f5c1b50cda437ee573f38b8f0017324bd
3
+ metadata.gz: ed95e6005b1c1325ace3a288f25b33d5e9a64b35
4
+ data.tar.gz: 9f780c279a89b8daea900809be1b648b9c9b3eb3
5
5
  SHA512:
6
- metadata.gz: 9ffcb13eab5be661c10bf40a546dcf2c3f1a87f1c1237c3b03f412f4d946553f1a2dffb89da9ffeea2e4e5df681444bc7dc8a68926c325030c09598b997e2761
7
- data.tar.gz: 401252584ef64dbd75da2ecc42c30ebf663fada4384836ad2aeccea962411aaf00bd5334ebc482904ae9346033d140e6b81c4670a873f7880fed89fb98338a69
6
+ metadata.gz: 6b2c03c72d08b4528f5bc7ae16cc9905626977ea7a72bc50491d35874d57acf92f42f37ad27edd91262b61ee54acc0482d4227ce23bdab5f317d0a1d4edd5330
7
+ data.tar.gz: 7d08a4a58cec028212220ab4b4f845bec886a379acb4d9c6e0499802342524f85f7ee79cc78d2e2daa2603985acf62deb41652a471ff1fc99b0ea4c1eb3b7b81
@@ -34,9 +34,23 @@ module MultiClient
34
34
 
35
35
  def self.with_tenant(tenant, &block)
36
36
  original_id = current_id
37
- self.current_id = tenant.id
38
- block.call
39
- self.current_id = original_id
37
+ begin
38
+ self.current_id = tenant.id
39
+ block.call
40
+ rescue
41
+ raise
42
+ ensure
43
+ self.current_id = original_id
44
+ end
40
45
  end
46
+
47
+ def self.master?
48
+ !!(current && current.identifier == Configuration.master_tenant_identifier)
49
+ end
50
+
51
+ def self.set_current_to_master
52
+ set_current_by_identifier(Configuration.master_tenant_identifier)
53
+ end
54
+
41
55
  end
42
56
  end
@@ -6,7 +6,7 @@ module MultiClient
6
6
  source_root File.expand_path('../templates', __FILE__)
7
7
 
8
8
  def generate_intializer
9
- copy_file 'multi_client.rb', 'config/initializers/multi_client.rb'
9
+ copy_file 'initializer.rb', 'config/initializers/multi_client.rb'
10
10
  end
11
11
  end
12
12
  end
@@ -60,4 +60,11 @@ MultiClient.configure do |config|
60
60
  # Default: config.no_subdomain_prefixes = ->(request) { ['www', '', nil] }
61
61
  #
62
62
  config.no_subdomain_prefixes = ->(request) { ['www', '', nil] }
63
+
64
+ # The master tenant is a special tenant. You can ask Tenant.master? to
65
+ # check, if the actual tenant is the master tenant.
66
+ #
67
+ # Default: config.master_tenant_identifier = '000'
68
+ #
69
+ config.master_tenant_identifier = '000'
63
70
  end
@@ -24,6 +24,8 @@ module MultiClient
24
24
 
25
25
  mattr_accessor(:force_client_scope_for_unscoped_callers) { [] }
26
26
 
27
+ mattr_accessor(:master_tenant_identifier) { '000' }
28
+
27
29
  def self.namespaced_model_name
28
30
  "MultiClient::#{model_name}"
29
31
  end
@@ -1,3 +1,3 @@
1
1
  module MultiClient
2
- VERSION = '2.1.0'.freeze
2
+ VERSION = '2.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
@@ -150,7 +150,7 @@ files:
150
150
  - config/routes.rb
151
151
  - db/migrate/001_create_multi_client_clients.rb
152
152
  - lib/generators/multi_client/install/install_generator.rb
153
- - lib/generators/multi_client/install/templates/multi_client.rb
153
+ - lib/generators/multi_client/install/templates/initializer.rb
154
154
  - lib/multi_client.rb
155
155
  - lib/multi_client/configuration.rb
156
156
  - lib/multi_client/engine.rb