Sha256: 5dd698a2ea3e145f76c13ce8259c8b73fd4a646feac6dfeb4e06d4f9f747e421

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 KB

Contents

class Object

  def self.lev_routine(options={})
    class_eval do
      include Lev::Routine unless options[:skip_routine_include]

      # Routine configuration
      options[:transaction] ||= Lev::TransactionIsolation.mysql_default.symbol
      @transaction_isolation = Lev::TransactionIsolation.new(options[:transaction])

      @job_class = options[:job_class]
      @active_job_enqueue_options = options[:active_job_enqueue_options]

      @raise_fatal_errors = options[:raise_fatal_errors]

      @delegates_to = options[:delegates_to]
      if @delegates_to
        uses_routine @delegates_to,
                     translations: {
                       outputs: { type: :verbatim },
                       inputs: { type: :verbatim }
                     }

        @express_output ||= @delegates_to.express_output
      end

      # Set this after dealing with "delegates_to" in case it set a value
      @express_output ||= options[:express_output] || self.name.demodulize.underscore

      if options[:use_jobba]
        self.create_status_proc = ->(*) { Jobba::Status.create! }
        self.find_status_proc = ->(id) { Jobba::Status.find!(id) }
      end
    end
  end

  def self.lev_handler(options={})
    class_eval do
      include Lev::Handler
    end

    # Do routine configuration
    options[:skip_routine_include] = true
    lev_routine(options)

    # Do handler configuration (none currently)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lev-12.1.0 lib/lev/object.rb
lev-12.0.0 lib/lev/object.rb
lev-11.0.0 lib/lev/object.rb
lev-10.1.0 lib/lev/object.rb