Sha256: 20c773109b20e1c870b91ad37bf40cae02854e9f8e9648a13f62918fc408426d
Contents?: true
Size: 747 Bytes
Versions: 1
Compression:
Stored size: 747 Bytes
Contents
require 'rack/request' require 'apartment/database' 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) Apartment::Database.switch database if database @app.call(env) end def parse_database_name(request) warn "[DEPRECATED] - Use #parse_tenant_name" parse_tenant_name(request) end def parse_tenant_name(request) raise "Override" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
apartment-0.23.1 | lib/apartment/elevators/generic.rb |