Class: Sidekiq::Middleware::MultiTenant::Server
- Inherits:
-
Object
- Object
- Sidekiq::Middleware::MultiTenant::Server
- Defined in:
- lib/activerecord-multi-tenant/sidekiq.rb
Overview
Pull the tenant out and run the current thread with it.
Instance Method Summary collapse
Instance Method Details
#call(_worker_class, msg, _queue, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/activerecord-multi-tenant/sidekiq.rb', line 22 def call(_worker_class, msg, _queue, &block) if msg.key?('multi_tenant') tenant = begin msg['multi_tenant']['class'].constantize.find(msg['multi_tenant']['id']) rescue ActiveRecord::RecordNotFound msg['multi_tenant']['id'] end MultiTenant.with(tenant, &block) else yield end end |