diff options
author | George Claghorn <george@basecamp.com> | 2018-12-24 15:16:22 -0500 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-12-25 21:32:35 -0500 |
commit | a5b2fff64ca0c1fa7be5124f40a251d991c10a85 (patch) | |
tree | 33a79841402b7151e52d9ad3949ce54f320c10aa /actionmailbox/app/models/action_mailbox/inbound_email/incineratable.rb | |
parent | 4298df00ae6219b9b5b7c40f281d4fa4d66f4383 (diff) | |
parent | dcddff1d2d0c695318670686a27429a76f20ae03 (diff) | |
download | rails-a5b2fff64ca0c1fa7be5124f40a251d991c10a85.tar.gz rails-a5b2fff64ca0c1fa7be5124f40a251d991c10a85.tar.bz2 rails-a5b2fff64ca0c1fa7be5124f40a251d991c10a85.zip |
Import Action Mailbox
Diffstat (limited to 'actionmailbox/app/models/action_mailbox/inbound_email/incineratable.rb')
-rw-r--r-- | actionmailbox/app/models/action_mailbox/inbound_email/incineratable.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/actionmailbox/app/models/action_mailbox/inbound_email/incineratable.rb b/actionmailbox/app/models/action_mailbox/inbound_email/incineratable.rb new file mode 100644 index 0000000000..825e300648 --- /dev/null +++ b/actionmailbox/app/models/action_mailbox/inbound_email/incineratable.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +# Ensure that the `InboundEmail` is automatically scheduled for later incineration if the status has been +# changed to `processed`. The later incineration will be invoked at the time specified by the +# `ActionMailbox.incinerate_after` time using the `IncinerationJob`. +module ActionMailbox::InboundEmail::Incineratable + extend ActiveSupport::Concern + + included do + after_update_commit :incinerate_later, if: -> { status_previously_changed? && processed? } + end + + def incinerate_later + ActionMailbox::IncinerationJob.schedule self + end + + def incinerate + Incineration.new(self).run + end +end |