Class: Penthouse::Tenants::OctopusShardTenant

Inherits:
OctopusSchemaTenant show all
Defined in:
lib/penthouse/tenants/octopus_shard_tenant.rb

Instance Attribute Summary collapse

Attributes inherited from SchemaTenant

#default_schema, #persistent_schemas, #tenant_schema

Attributes inherited from BaseTenant

#identifier

Instance Method Summary collapse

Methods inherited from OctopusSchemaTenant

#create, #delete, #exists?

Methods inherited from SchemaTenant

#create, #delete, #exists?

Methods included from Migratable

#migrate

Methods inherited from BaseTenant

#create, #delete

Constructor Details

#initialize(identifier, shard:, tenant_schema: "public", **options) ⇒ OctopusShardTenant

Returns a new instance of OctopusShardTenant.

Parameters:

  • identifier (String, Symbol)

    An identifier for the tenant

  • shard (String, Symbol)

    the configured Octopus shard to use for this tenant

  • tenant_schema (String) (defaults to: "public")

    your tenant’s schema name within the Postgres shard, typically just ‘public’ as the shard should be dedicated



21
22
23
24
# File 'lib/penthouse/tenants/octopus_shard_tenant.rb', line 21

def initialize(identifier, shard:, tenant_schema: "public", **options)
  self.shard = shard
  super(identifier, tenant_schema: tenant_schema, **options)
end

Instance Attribute Details

#shardObject

Returns the value of attribute shard.



15
16
17
# File 'lib/penthouse/tenants/octopus_shard_tenant.rb', line 15

def shard
  @shard
end

Instance Method Details

#call(&block) {|ShardTenant| ... } ⇒ void

This method returns an undefined value.

switches to the relevant Octopus shard, and processes the block

Parameters:

  • block (Block)

    The code to execute within the connection to the shard

Yields:

  • (ShardTenant)

    The current tenant instance



30
31
32
# File 'lib/penthouse/tenants/octopus_shard_tenant.rb', line 30

def call(&block)
  super(shard: shard, &block)
end