Sha256: 675d44e0957f1f0c27d34a91ac7da2bdbcb63d68e1b65645c6f3e7e418e933eb

Contents?: true

Size: 1011 Bytes

Versions: 9

Compression:

Stored size: 1011 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"

module AcidicJob
  module PerformTransactionallyExtension
    extend ActiveSupport::Concern

    class_methods do
      # rubocop:disable Metrics/MethodLength
      def perform_transactionally(*args)
        attributes = if defined?(ActiveJob) && self < ActiveJob::Base
                       {
                         adapter: "activejob",
                         job_name: name,
                         job_args: job_or_instantiate(*args).serialize
                       }
                     elsif defined?(Sidekiq) && include?(Sidekiq::Worker)
                       {
                         adapter: "sidekiq",
                         job_name: name,
                         job_args: args
                       }
                     else
                       raise UnknownJobAdapter
                     end

        AcidicJob::Staged.create!(attributes)
      end
      # rubocop:enable Metrics/MethodLength
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
acidic_job-0.7.7 lib/acidic_job/perform_transactionally_extension.rb
acidic_job-0.7.6 lib/acidic_job/perform_transactionally_extension.rb
acidic_job-0.7.5 lib/acidic_job/perform_transactionally_extension.rb
acidic_job-0.7.4 lib/acidic_job/perform_transactionally_extension.rb
acidic_job-0.7.3 lib/acidic_job/perform_transactionally_extension.rb
acidic_job-0.7.2 lib/acidic_job/perform_transactionally_extension.rb
acidic_job-0.7.1 lib/acidic_job/perform_transactionally_extension.rb
acidic_job-0.7.0 lib/acidic_job/perform_transactionally_extension.rb
acidic_job-0.6.0 lib/acidic_job/perform_transactionally_extension.rb