I had to remove these lines since they were actually breaking the desired functionality. Can you review and merge? #8

Merged
merged 2 commits into from May 14, 2013
Jump to file
+3 −10
Split
View
@@ -154,11 +154,6 @@ def sendgrid_ganalytics_options(options)
options.each { |option| @ganalytics_options << option if VALID_GANALYTICS_OPTIONS.include?(option[0].to_sym) }
end
- # Call within mailer method to set unique args for this email.
- def sendgrid_unique_args(args)
- @sg_unique_args = args
- end
-
# only override the appropriate methods for the current ActionMailer version
if ActionMailer::Base.respond_to?(:mail)
@@ -201,6 +196,9 @@ def create!(method_name, *parameters)
def sendgrid_json_headers(mail)
header_opts = {}
+ #if not called within the mailer method, this will be nil so we default to empty hash
+ @sg_unique_args = @sg_unique_args || {}
+
# set the unique arguments
if @sg_unique_args || self.class.default_sg_unique_args
unique_args = self.class.default_sg_unique_args || {}
@@ -245,11 +243,6 @@ def sendgrid_json_headers(mail)
header_opts[:filters] = filters_hash_from_options(enabled_opts, @sg_disabled_options)
end
- # Set unique_args
- if @sg_unique_args && !@sg_unique_args.empty?
- header_opts[:unique_args] = @sg_unique_args
- end
-
header_opts.to_json.gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3')
end