Class: Rack::MultiTenant::TenantStrategies::EnvVariable

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/multitenant/tenant_strategies/env_variable.rb

Instance Method Summary collapse

Constructor Details

#initialize(env = ENV["TENANT"], &getter) ⇒ EnvVariable

env: Environment variable containing the tenant or tenant key. &getter: optional block. If specified, the env variable will be passed in.

>> ENV["TENANT"] = "foo"
>> s = Rack::MultiTenant::TenantStrategies::EnvVariable.new
>> s.call(:stub_request)
=> "foo"

>> s2 = Rack::MultiTenant::TenantStrategies::EnvVariable.new(&:to_sym)
>> s2.call(:stub_request)
=> :foo


14
15
16
# File 'lib/rack/multitenant/tenant_strategies/env_variable.rb', line 14

def initialize(env = ENV["TENANT"], &getter)
  @env = (getter || lambda {|k| k}).call(env)
end

Instance Method Details

#call(_) ⇒ Object



18
19
20
# File 'lib/rack/multitenant/tenant_strategies/env_variable.rb', line 18

def call(_)
  @env
end