Sha256: c43cdb190f3ffa5994176be173fed5572fe7c0967c1c56070b146405a3f71f94

Contents?: true

Size: 753 Bytes

Versions: 2

Compression:

Stored size: 753 Bytes

Contents

module Lev
  class NoBackgroundJob

    # Provide null object pattern methods for background jobs; routines should
    # not be checking their own status (they should know it), and outside callers
    # should not be checking status unless the background job is a real one.

    def set_progress(*); end
    def save(*); end
    def add_error(*); end

    Lev::BackgroundJob::STATES.each do |state|
      define_method("#{state}!") do; end
    end

    def self.method_missing(method_sym, *args, &block)
      if Lev::BackgroundJob.new.respond_to?(method_sym)
        raise NameError,
              "'#{method_sym}' is Lev::BackgroundJob query method, and those cannot be called on NoBackgroundJob"
      else
        super
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lev-6.0.0 lib/lev/no_background_job.rb
lev-5.0.0 lib/lev/no_background_job.rb