Class: Rack::MultiTenant::TenantStrategies::EnvVariable
- Inherits:
-
Object
- Object
- Rack::MultiTenant::TenantStrategies::EnvVariable
- Defined in:
- lib/rack/multitenant/tenant_strategies/env_variable.rb
Instance Method Summary collapse
- #call(_) ⇒ Object
-
#initialize(env = ENV["TENANT"], &getter) ⇒ EnvVariable
constructor
env: Environment variable containing the tenant or tenant key.
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 |