From 5c01d4c6849142a654af18384b3095cfd2560d78 Mon Sep 17 00:00:00 2001 From: Micha Zana Date: Thu, 13 Nov 2014 10:40:01 +0200 Subject: [PATCH 1/3] sendgrid pool header support --- lib/sendgrid.rb | 9 ++++++++- sendgrid.gemspec | 3 --- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/sendgrid.rb b/lib/sendgrid.rb index 688493d..334b204 100644 --- a/lib/sendgrid.rb +++ b/lib/sendgrid.rb @@ -28,7 +28,7 @@ class << self :default_footer_text, :default_spamcheck_score, :default_sg_unique_args end attr_accessor :sg_category, :sg_options, :sg_disabled_options, :sg_recipients, :sg_substitutions, - :subscriptiontrack_text, :footer_text, :spamcheck_score, :sg_unique_args + :subscriptiontrack_text, :footer_text, :spamcheck_score, :sg_unique_args, :sg_pool end # NOTE: This commented-out approach may be a "safer" option for Rails 3, but it @@ -103,6 +103,10 @@ def sendgrid_category(category) @sg_category = category end + def sendgrid_pool(pool_name) + @sg_pool = pool_name + end + # Call within mailer method to set unique args for this email. # Merged with class-level unique args, if any exist. def sendgrid_unique_args(unique_args = {}) @@ -210,6 +214,9 @@ def sendgrid_json_headers(mail) header_opts[:unique_args] = unique_args unless unique_args.empty? end + # Set pool + header_opts[:ip_pool] = @sg_pool if @sg_pool + # Set category if @sg_category && @sg_category == :use_subject_lines header_opts[:category] = mail.subject diff --git a/sendgrid.gemspec b/sendgrid.gemspec index 0df55dd..c699265 100644 --- a/sendgrid.gemspec +++ b/sendgrid.gemspec @@ -42,20 +42,17 @@ Gem::Specification.new do |s| s.add_development_dependency(%q, [">= 0"]) s.add_development_dependency(%q, ["~> 1.0.0"]) s.add_development_dependency(%q, ["~> 1.5.1"]) - s.add_runtime_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, ["~> 1.0.0"]) s.add_dependency(%q, ["~> 1.5.1"]) - s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, ["~> 1.0.0"]) s.add_dependency(%q, ["~> 1.5.1"]) - s.add_dependency(%q, [">= 0"]) end end From b2f5ba940b4e8c4253cb096af9acb6d2e5055b98 Mon Sep 17 00:00:00 2001 From: Micha Zana Date: Thu, 13 Nov 2014 17:02:35 +0200 Subject: [PATCH 2/3] concacenate category --- lib/sendgrid.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/sendgrid.rb b/lib/sendgrid.rb index 334b204..073c86f 100644 --- a/lib/sendgrid.rb +++ b/lib/sendgrid.rb @@ -103,6 +103,12 @@ def sendgrid_category(category) @sg_category = category end + # Call within mailer method to concatenate sendgrid categories. + # Will not remove duplicates. + def append_sendgrid_category(category) + @sg_category = @sg_category + category + end + def sendgrid_pool(pool_name) @sg_pool = pool_name end From 78c20d239fdbbfd87b00d7de04f6c56357036809 Mon Sep 17 00:00:00 2001 From: Micha Zana Date: Thu, 13 Nov 2014 18:06:43 +0200 Subject: [PATCH 3/3] concatenate category when no array exists --- lib/sendgrid.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sendgrid.rb b/lib/sendgrid.rb index 073c86f..2322092 100644 --- a/lib/sendgrid.rb +++ b/lib/sendgrid.rb @@ -106,7 +106,7 @@ def sendgrid_category(category) # Call within mailer method to concatenate sendgrid categories. # Will not remove duplicates. def append_sendgrid_category(category) - @sg_category = @sg_category + category + @sg_category = (@sg_category || []) + category end def sendgrid_pool(pool_name)