class Duties::Next

Attributes

position[R]
record[R]

Public Class Methods

call(record, position) click to toggle source
# File lib/duties/next.rb, line 2
def self.call(record, position)
  new(record, position).call
end
new(record, position) click to toggle source
# File lib/duties/next.rb, line 6
def initialize(record, position)
  @record, @position = record, position
end

Public Instance Methods

call() click to toggle source
# File lib/duties/next.rb, line 10
def call
  # We're done here. Stop.
  return if any_failures?
  return unless finished_current? && more_to_come?

  activity_records.by_position(position + 1).each do |activity|
    Duties::ActivityJob.perform_async activity.id
  end
end

Private Instance Methods

any_failures?() click to toggle source
# File lib/duties/next.rb, line 26
def any_failures?
  activity_records.by_position(position).failures.any?
end
finished_current?() click to toggle source
# File lib/duties/next.rb, line 30
def finished_current?
  activity_records.by_position(position).all? &:success?
end
more_to_come?() click to toggle source
# File lib/duties/next.rb, line 34
def more_to_come?
  activity_records.by_position(position + 1).any?
end