Sha256: be40aa5756738911a5a8eb1338284be9813e5784a29920ee73a8ccb6c46f916d

Contents?: true

Size: 703 Bytes

Versions: 6

Compression:

Stored size: 703 Bytes

Contents

class Belated
  # Testing helpers
  # Enable or disable testing
  class Testing
    @@testing = false

    def self.inline?
      @@testing == true
    end

    def self.inline!
      @@testing = true
    end

    def self.test_mode_off!
      @@testing = false
    end
  end
end

class Belated
  # A client that can perform jobs inline
  class Client
    alias old_perform perform
    def perform(job, at: nil, max_retries: 5, active_job: false)
      if Belated::Testing.inline?
        if job.respond_to?(:call)
          job.call
        else
          job.perform
        end
      else
        old_perform(job, at: at, max_retries: max_retries, active_job: active_job)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
belated-0.9.0 lib/belated/testing.rb
belated-0.8.3 lib/belated/testing.rb
belated-0.8.2 lib/belated/testing.rb
belated-0.8.1 lib/belated/testing.rb
belated-0.8.0 lib/belated/testing.rb
belated-0.7.0 lib/belated/testing.rb