Class: ActsAsTenant::Sidekiq::Server

Inherits:
BaseMiddleware show all
Includes:
Sidekiq::ServerMiddleware
Defined in:
lib/acts_as_tenant/sidekiq.rb

Overview

Pull the tenant out and run the current thread with it.

Instance Method Summary collapse

Methods inherited from BaseMiddleware

sidekiq_7_and_up?

Instance Method Details

#call(worker_class, msg, queue) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/acts_as_tenant/sidekiq.rb', line 29

def call(worker_class, msg, queue)
  if msg.has_key?("acts_as_tenant")
    klass = msg["acts_as_tenant"]["class"].constantize
    id = msg["acts_as_tenant"]["id"]
     = klass.class_eval(&ActsAsTenant.configuration.job_scope).find(id)
    ActsAsTenant.with_tenant  do
      yield
    end
  else
    yield
  end
end