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) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/activerecord-multi-tenant/sidekiq.rb', line 19 def call(worker_class, msg, queue) if msg.has_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) do yield end else yield end end |