Class: ActsAsTenant::Sidekiq::Client

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

Overview

Get the current tenant and store in the message to be sent to Sidekiq.

Instance Method Summary collapse

Methods inherited from BaseMiddleware

sidekiq_7_and_up?

Instance Method Details

#call(worker_class, msg, queue, redis_pool) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/acts_as_tenant/sidekiq.rb', line 12

def call(worker_class, msg, queue, redis_pool)
  if ActsAsTenant.current_tenant.present?
    msg["acts_as_tenant"] ||=
      {
        "class" => ActsAsTenant.current_tenant.class.name,
        "id" => ActsAsTenant.current_tenant.id
      }
  end

  yield
end