Skip to content
Browse files

Document ActionMailer::LogSubscriber and ActionMailer::DeliveryMethod…

…s::ClassMethods
  • Loading branch information...
1 parent e47c85c commit 41c3670fab23f3eb1acbd415d47cbf36dbc36bca @zzak zzak committed
View
1 actionmailer/lib/action_mailer/delivery_methods.rb
@@ -38,6 +38,7 @@ module DeliveryMethods
add_delivery_method :test, Mail::TestMailer
end
+ # Helpers for creating and wrapping delivery behavior, used by DeliveryMethods.
module ClassMethods
# Provides a list of emails that have been delivered by Mail::TestMailer
delegate :deliveries, :deliveries=, to: Mail::TestMailer
View
5 actionmailer/lib/action_mailer/log_subscriber.rb
@@ -1,5 +1,8 @@
module ActionMailer
+ # Implements the ActiveSupport::LogSubscriber for logging notifications when
+ # email is delivered and received.
class LogSubscriber < ActiveSupport::LogSubscriber
+ # An email was delivered.
def deliver(event)
return unless logger.info?
recipients = Array(event.payload[:to]).join(', ')
@@ -7,12 +10,14 @@ def deliver(event)
debug(event.payload[:mail])
end
+ # An email was received.
def receive(event)
return unless logger.info?
info("\nReceived mail (#{event.duration.round(1)}ms)")
debug(event.payload[:mail])
end
+ # Use the logger configured for ActionMailer::Base
def logger
ActionMailer::Base.logger
end

0 comments on commit 41c3670

Please sign in to comment.
Something went wrong with that request. Please try again.