class MultiTenantSupport::Sidekiq::Server

Public Instance Methods

call(worker_instance, msg, queue) { || ... } click to toggle source
# File lib/multi_tenant_support/sidekiq.rb, line 18
def call(worker_instance, msg, queue)
  if msg.has_key?("multi_tenant_support")
    tenant_klass = msg["multi_tenant_support"]["class"].constantize
    tenant_id = msg["multi_tenant_support"]["id"]
    
    tenant_account = nil
    MultiTenantSupport.allow_read_across_tenant do
      tenant_account = tenant_klass.find tenant_id
    end

    MultiTenantSupport.under_tenant tenant_account do
      yield
    end
  else
    yield
  end
end