Sha256: e1560972b72b3aa5d6becda02c3666ac379565ea5c422673908b36917d240903
Contents?: true
Size: 661 Bytes
Versions: 7
Compression:
Stored size: 661 Bytes
Contents
require 'rack/request' require 'apartment/tenant' module Apartment module Elevators # Provides a rack based tenant switching solution based on request # class Generic def initialize(app, processor = nil) @app = app @processor = processor || method(:parse_tenant_name) end def call(env) request = Rack::Request.new(env) database = @processor.call(request) if database Apartment::Tenant.switch(database) { @app.call(env) } else @app.call(env) end end def parse_tenant_name(request) raise "Override" end end end end
Version data entries
7 entries across 7 versions & 2 rubygems