Permalink
Browse files

Let mail() and create!() return what their overridden versions do.

This allows us to continue to do MailerClass.mailer_method.deliver
  • Loading branch information...
1 parent 4e93240 commit 4ff3e216be882bd37fef4b51222ea41da06a15c9 @einarmagnus committed Mar 14, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/sendgrid.rb
View
@@ -141,14 +141,15 @@ def sendgrid_unique_args(args)
# Sets the custom X-SMTPAPI header after creating the email but before delivery
# NOTE: This override is used for Rails 3 ActionMailer classes.
def mail(headers={}, &block)
- super
+ m = super
if @sg_substitutions && !@sg_substitutions.empty?
@sg_substitutions.each do |find, replace|
raise ArgumentError.new("Array for #{find} is not the same size as the recipient array") if replace.size != @sg_recipients.size
end
end
puts "SendGrid X-SMTPAPI: #{sendgrid_json_headers(message)}" if Object.const_defined?("SENDGRID_DEBUG_OUTPUT") && SENDGRID_DEBUG_OUTPUT
self.headers['X-SMTPAPI'] = sendgrid_json_headers(message)
+ m
end
else

2 comments on commit 4ff3e21

It should be better to use super.tap or returning() for preserve the return value

Owner

einarmagnus replied Jun 21, 2012

Perhaps. Semantically there is no difference, but it may be safer if someone edits this further.

Please sign in to comment.