Class: Tenantify::Middleware::Strategies::Host
- Inherits:
-
Object
- Object
- Tenantify::Middleware::Strategies::Host
- Defined in:
- lib/tenantify/middleware/strategies/host.rb
Overview
Strategy to get the tenant from the request host. It expect the tenant name from configuration.
Instance Method Summary collapse
-
#initialize(config) ⇒ Host
constructor
Constructor.
-
#tenant_for(env) ⇒ Symbol?
Finds a tenant for the given env.
Constructor Details
#initialize(config) ⇒ Host
Constructor. It receives a hash with tenants as keys and arrays of hosts as values.
24 25 26 |
# File 'lib/tenantify/middleware/strategies/host.rb', line 24 def initialize config @config = config end |
Instance Method Details
#tenant_for(env) ⇒ Symbol?
Finds a tenant for the given env.
32 33 34 35 36 |
# File 'lib/tenantify/middleware/strategies/host.rb', line 32 def tenant_for env host = env["SERVER_NAME"] correspondence[host] end |