Class: MultiTenantSupport::Sidekiq::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/multi_tenant_support/sidekiq.rb

Instance Method Summary collapse

Instance Method Details

#call(worker_instance, msg, queue) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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"]
    
     = nil
    MultiTenantSupport.allow_read_across_tenant do
       = tenant_klass.find tenant_id
    end

    MultiTenantSupport.under_tenant  do
      yield
    end
  else
    yield
  end
end