class FeedbackEmailJob < EmailJob - FeedbackEmailJob has no descriptive comment
class SendingDisabledError < RuntimeError; end - FeedbackEmailJob::SendingDisabledError has no descriptive comment
self.mailer = FeedbackMailer
self.email = :send_feedback
rescue_from SendingDisabledError do
reschedule_job
end
before_perform if: :feedback_sending_disabled? do
raise SendingDisabledError, "Feedback sending is currently disabled"
end
private
def reschedule_job(time = 1.hour.from_now)
self.class.set(wait_until: time).perform_later(*arguments)
end
def feedback_sending_disabled? - FeedbackEmailJob#feedback_sending_disabled? doesn't depend on instance state (maybe move it to another class?)
Site.disable_feedback_sending?
end
end