penthouse 0.4.2 → 0.5.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: 9555293622bdf6cf3007d78c7898faea5d5bbf11
4
- data.tar.gz: 1329b15a6cf64e26e5608cb80b3c00b53b050c53
3
+ metadata.gz: 793411262ca8ce30ae1f03de55a78f76d4f4d9a2
4
+ data.tar.gz: 28306b0b4536d295809080968dfd0a2fd7621318
5
5
  SHA512:
6
- metadata.gz: fbd7fd91293a0c5e75149638713f0c2f1e2ca024023d73f22a9523dad9376eed564691385b41cbc667ae3947421142d83bb79d95a71fe64663d743fbccaf4f93
7
- data.tar.gz: 6f54b9485a72214847acdab9ab0afada002bea667836eff675354fde1d08bebb78ca9362c147e6b3021c2657d0360a7085a1d9432fefe7ce2a9ef8ce152fd1fb
6
+ metadata.gz: 16ce8d5d39cdc76572d89a91ea895986fbd90d9fb59021f6f5a9fd65a7dc76f49121752c69a49d63fceaa48f0da2132547573c8b3df0f472668adc7e0b7140ee
7
+ data.tar.gz: 5948007a8f5c28089a94e3f48d60f55110b5f67c4b2cc9bf2fb7b7372f5047930253610d0b1d3ec66e5594a2470ebaea70b3df375a273257a0237e27d6832513
@@ -14,14 +14,15 @@ module Penthouse
14
14
  module Tenants
15
15
  class OctopusSchemaTenant < SchemaTenant
16
16
 
17
- # ensures we're on the master Octopus shard, just updates the schema name
18
- # with the tenant name
17
+ # ensures we're on the correct Octopus shard, then just updates the schema
18
+ # name with the tenant name
19
+ # @param shard [String, Symbol] The shard to execute within, usually master
19
20
  # @param block [Block] The code to execute within the schema
20
21
  # @yield [SchemaTenant] The current tenant instance
21
22
  # @return [void]
22
- def call(&block)
23
- Octopus.using(:master) do
24
- super
23
+ def call(shard: :master, &block)
24
+ Octopus.using(shard) do
25
+ super(&block)
25
26
  end
26
27
  end
27
28
 
@@ -1,29 +1,26 @@
1
1
  #
2
- # The ShardTenant class relies upon Octopus [1], it switches to a different
3
- # shard per tenant, allowing for each tenant to have their own database, 100%
4
- # isolated from other tenants in terms of data and performance.
2
+ # The OctopusShardTenant class relies upon Octopus [1], it switches to a
3
+ # different shard per tenant, allowing for each tenant to have their own
4
+ # database, 100% isolated from other tenants in terms of data and performance.
5
5
  #
6
6
  # [1]: (https://github.com/thiagopradi/octopus)
7
7
  #
8
8
 
9
- require_relative './base_tenant'
10
- require 'octopus'
11
- require_relative './migratable'
9
+ require_relative './octopus_schema_tenant'
12
10
 
13
11
  module Penthouse
14
12
  module Tenants
15
- class OctopusShardTenant < BaseTenant
16
- include Migratable
13
+ class OctopusShardTenant < OctopusSchemaTenant
17
14
 
18
15
  attr_accessor :shard
19
16
  private :shard=
20
17
 
21
18
  # @param identifier [String, Symbol] An identifier for the tenant
22
19
  # @param shard [String, Symbol] the configured Octopus shard to use for this tenant
23
- def initialize(identifer, shard:)
24
- super(identifier)
20
+ # @param tenant_schema [String] your tenant's schema name within the Postgres shard, typically just 'public' as the shard should be dedicated
21
+ def initialize(identifer, shard:, tenant_schema: "public", **options)
25
22
  self.shard = shard
26
- freeze
23
+ super(identifier, tenant_schema: tenant_schema, **options)
27
24
  end
28
25
 
29
26
  # switches to the relevant Octopus shard, and processes the block
@@ -31,9 +28,7 @@ module Penthouse
31
28
  # @yield [ShardTenant] The current tenant instance
32
29
  # @return [void]
33
30
  def call(&block)
34
- Octopus.using(shard) do
35
- block.yield(self)
36
- end
31
+ super(shard: shard, &block)
37
32
  end
38
33
  end
39
34
  end
@@ -1,3 +1,3 @@
1
1
  module Penthouse
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: penthouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Townsend