Module: ActiveJob::Inlined

Defined in:
lib/active_job/inlined.rb,
lib/active_job/inlined/version.rb

Defined Under Namespace

Classes: Proxy

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(klass) ⇒ Object



17
18
19
# File 'lib/active_job/inlined.rb', line 17

def self.extended(klass)
  klass.include ActiveJob::ExecutionContext::Integration
end

Instance Method Details

#inline_exempt(context = nil, &block) ⇒ Object

By default, jobs are considered inlineable. But they can declare themselves exempt by calling ‘inline_exempt`, like this:

class Post::PublishJob < ApplicationJob
  inline_exempt
  inline_exempt -> job { job.arguments.size.even? }
  inline_exempt { |job| job.arguments.size.even? }
end


42
43
44
# File 'lib/active_job/inlined.rb', line 42

def inline_exempt(context = nil, &block)
  @inline_exemption = context || block || -> { true }
end

#inline_exempt?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/active_job/inlined.rb', line 29

def inline_exempt?
  @inline_exemption&.call(self)
end

#inlineable?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/active_job/inlined.rb', line 25

def inlineable?
  executing? && inline_enrolled?
end

#inlinedObject



21
22
23
# File 'lib/active_job/inlined.rb', line 21

def inlined
  inlineable? ? Proxy.new(self) : self
end