1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionmailbox/app/models/action_mailbox/inbound_email/routable.rb

25 lines
843 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# A newly received +InboundEmail+ will not be routed synchronously as part of ingress controller's receival.
# Instead, the routing will be done asynchronously, using a +RoutingJob+, to ensure maximum parallel capacity.
2018-12-12 19:34:05 -05:00
#
# By default, all newly created +InboundEmail+ records that have the status of +pending+, which is the default,
2018-12-12 19:34:05 -05:00
# will be scheduled for automatic, deferred routing.
module ActionMailbox::InboundEmail::Routable
2018-09-19 19:40:56 -04:00
extend ActiveSupport::Concern
included do
2018-10-17 10:38:51 -04:00
after_create_commit :route_later, if: :pending?
2018-09-19 19:40:56 -04:00
end
# Enqueue a +RoutingJob+ for this +InboundEmail+.
2018-09-28 14:32:44 -04:00
def route_later
ActionMailbox::RoutingJob.perform_later self
2018-09-28 14:32:44 -04:00
end
# Route this +InboundEmail+ using the routing rules declared on the +ApplicationMailbox+.
def route
ApplicationMailbox.route self
end
2018-09-19 19:40:56 -04:00
end