Class: Rack::MultiTenant::GetIdentity

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

Defined Under Namespace

Classes: Next

Instance Method Summary collapse

Constructor Details

#initialize(app, user_key = "REMOTE_USER", &getter) ⇒ GetIdentity

Returns a new instance of GetIdentity.



3
4
5
# File 'lib/rack/multitenant/get_identity.rb', line 3

def initialize(app, user_key = "REMOTE_USER", &getter)
  @app, @user_key, @getter = app, user_key, getter
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
# File 'lib/rack/multitenant/get_identity.rb', line 7

def call(env)
  user, tenant = env.values_at(@user_key, "rack.multitenant.current_tenant")
  Next.new(@app, env).call(@getter.call(user, tenant))
end