Module: CanvasSync::JobUniqueness::OnConflict
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/canvas_sync/job_uniqueness/on_conflict.rb,
lib/canvas_sync/job_uniqueness/on_conflict/log.rb,
lib/canvas_sync/job_uniqueness/on_conflict/base.rb,
lib/canvas_sync/job_uniqueness/on_conflict/raise.rb,
lib/canvas_sync/job_uniqueness/on_conflict/reject.rb,
lib/canvas_sync/job_uniqueness/on_conflict/reschedule.rb,
lib/canvas_sync/job_uniqueness/on_conflict/null_strategy.rb
Defined Under Namespace
Classes: Base, Log, NullStrategy, Raise, Reject, Reschedule
Class Method Summary
collapse
Class Method Details
.lookup(strategy) ⇒ Object
36
37
38
39
40
|
# File 'lib/canvas_sync/job_uniqueness/on_conflict.rb', line 36
def lookup(strategy)
matching_strategy(strategy.to_s.camelize) ||
CanvasSync::JobUniqueness.config.conflict_strategies[strategy] ||
raise(StrategyNotFound, "on_conflict: #{strategy} is not found. Is it declared in the configuration?")
end
|
.validate!(on_conflict, lock_strategy) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/canvas_sync/job_uniqueness/on_conflict.rb', line 42
def validate!(on_conflict, lock_strategy)
on_conflict = { enqueue: on_conflict, perform: on_conflict } unless on_conflict.is_a?(Hash)
lock_strategy = Strategy.lookup(lock_strategy) if lock_strategy.is_a?(Symbol)
on_conflict.each do |origin, strategy|
strategy = OnConflict.lookup(strategy) if strategy.is_a?(Symbol)
if lock_strategy.locks_on.include?(origin) && !strategy.valid_for.include?(origin)
raise ArgumentError, "(#{origin.to_s.titleize}) conflict strategy #{strategy.name.underscore} is not valid for lock strategy #{lock_strategy.name.underscore}"
end
end
end
|