Class: CanvasSync::JobUniqueness::OnConflict::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/canvas_sync/job_uniqueness/on_conflict/base.rb

Direct Known Subclasses

Log, NullStrategy, Raise, Reject, Reschedule

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lock_context, redis_pool = nil) ⇒ Base

Returns a new instance of Base.



18
19
20
21
# File 'lib/canvas_sync/job_uniqueness/on_conflict/base.rb', line 18

def initialize(lock_context, redis_pool = nil)
  @lock_context = lock_context
  @redis_pool = redis_pool
end

Instance Attribute Details

#lock_contextObject (readonly)

Returns the value of attribute lock_context.



4
5
6
# File 'lib/canvas_sync/job_uniqueness/on_conflict/base.rb', line 4

def lock_context
  @lock_context
end

#redis_poolObject (readonly)

Returns the value of attribute redis_pool.



5
6
7
# File 'lib/canvas_sync/job_uniqueness/on_conflict/base.rb', line 5

def redis_pool
  @redis_pool
end

Class Method Details

.valid_for(*origins) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/canvas_sync/job_uniqueness/on_conflict/base.rb', line 9

def self.valid_for(*origins)
  if origins.present?
    orgins = Array(origins).map(&:to_sym)
    self._valid_for = origins
  else
    self._valid_for || [:enqueue, :perform]
  end
end

Instance Method Details

#callObject

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/canvas_sync/job_uniqueness/on_conflict/base.rb', line 23

def call
  raise NotImplementedError, "needs to be implemented in child class"
end

#replace?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/canvas_sync/job_uniqueness/on_conflict/base.rb', line 27

def replace?
  is_a?(Replace)
end