From 4ff3e216be882bd37fef4b51222ea41da06a15c9 Mon Sep 17 00:00:00 2001 From: Einar Boson Date: Wed, 14 Mar 2012 16:53:21 +0100 Subject: [PATCH] Let mail() and create!() return what their overridden versions do. This allows us to continue to do MailerClass.mailer_method.deliver --- lib/sendgrid.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sendgrid.rb b/lib/sendgrid.rb index 0ce9caf..23dffe6 100644 --- a/lib/sendgrid.rb +++ b/lib/sendgrid.rb @@ -141,7 +141,7 @@ 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 @@ -149,6 +149,7 @@ def mail(headers={}, &block) 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