Class: Tenantify::Middleware::Strategies::Default

Inherits:
Object
  • Object
show all
Defined in:
lib/tenantify/middleware/strategies/default.rb

Overview

Strategy to return always the same tenant.

Examples:

Using Default strategy:

config   = {:tenant => :a_tenant}
strategy = Tenantify::Middleware::Strategies::Default.new(config)

env = {} # any environment
strategy.tenant_for(env) # => :a_tenant

Constant Summary collapse

NoTenantGivenError =

No tenant given.

Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Default

Constructor.

Parameters:

  • the (Hash)

    strategy configuration.

  • :tenant (Hash)

    a customizable set of options



20
21
22
# File 'lib/tenantify/middleware/strategies/default.rb', line 20

def initialize config
  @config = config
end

Instance Method Details

#tenant_for(_env) ⇒ Symbol?

Finds a tenant for the given env.

Parameters:

  • the (rack_environment)

    rack environment.

Returns:

  • (Symbol, nil)

    the found tenant of nil.



28
29
30
# File 'lib/tenantify/middleware/strategies/default.rb', line 28

def tenant_for _env
  tenant
end