Module: ActiveRecord::Tenanted::Job

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_record/tenanted/job.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#deserialize(job_data) ⇒ Object



23
24
25
26
# File 'lib/active_record/tenanted/job.rb', line 23

def deserialize(job_data)
  super
  @tenant = job_data.fetch("tenant", nil)
end

#initializeObject



12
13
14
15
16
17
# File 'lib/active_record/tenanted/job.rb', line 12

def initialize(...)
  super
  if klass = ActiveRecord::Tenanted.connection_class
    @tenant = klass.current_tenant
  end
end

#perform_nowObject



28
29
30
31
32
33
34
# File 'lib/active_record/tenanted/job.rb', line 28

def perform_now
  if tenant.present? && (klass = ActiveRecord::Tenanted.connection_class)
    klass.with_tenant(tenant) { super }
  else
    super
  end
end

#serializeObject



19
20
21
# File 'lib/active_record/tenanted/job.rb', line 19

def serialize
  super.merge!({ "tenant" => tenant })
end