lib/rocket_job/plugins/singleton.rb in rocketjob-3.4.3 vs lib/rocket_job/plugins/singleton.rb in rocketjob-3.5.0
- old
+ new
@@ -6,20 +6,19 @@
module Singleton
extend ActiveSupport::Concern
included do
# Validation prevents a new job from being saved while one is already running
- validates_each :state do |record, attr, value|
+ validates_each :state do |record, attr, _value|
if (record.running? || record.queued? || record.paused?) && record.rocket_job_singleton_active?
record.errors.add(attr, "Another instance of #{record.class.name} is already queued or running")
end
end
# Returns [true|false] whether another instance of this job is already active
def rocket_job_singleton_active?
- self.class.where(:state.in => [:running, :queued], :id.ne => id).exists?
+ self.class.where(:state.in => %i[running queued], :id.ne => id).exists?
end
end
-
end
end
end