Sha256: aa47cbdabb10d8f19f45371727c5ce9c1e5bdfa2c16ef3d0994f716c4f38f38f
Contents?: true
Size: 826 Bytes
Versions: 1
Compression:
Stored size: 826 Bytes
Contents
# The base class for all jobs that should be performed in the context of a particular Shop's API session. The first # argument to any job inheriting from this class must be the domain of the relevant store, so that the appropriate # Shop model can be fetched and the temporary API session created. module DiscoApp class ShopJob < ActiveJob::Base queue_as :default before_perform { |job| find_shop(job) } before_enqueue { |job| find_shop(job) } around_enqueue { |job, block| shop_context(job, block) } around_perform { |job, block| shop_context(job, block) } private def find_shop(job) @shop ||= Shop.find_by!(shopify_domain: job.arguments.first) end def shop_context(job, block) @shop.temp { block.call(job.arguments) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
disco_app-0.6.0 | app/jobs/disco_app/shop_job.rb |