Sha256: 9a73ee747e2b62b2ba03a39d00a3a85188d1bae4c7e37cd9f34f436e0b6412f3

Contents?: true

Size: 660 Bytes

Versions: 4

Compression:

Stored size: 660 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)
      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)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
belated-0.6.7 lib/belated/testing.rb
belated-0.6.6 lib/belated/testing.rb
belated-0.6.5 lib/belated/testing.rb
belated-0.6.4 lib/belated/testing.rb