Module: SendGrid
- Defined in:
- lib/sendgrid.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VALID_OPTIONS =
[ :opentrack, :clicktrack, :ganalytics, :gravatar, :subscriptiontrack, :footer, :spamcheck ]
Class Method Summary collapse
Instance Method Summary collapse
-
#create!(method_name, *parameters) ⇒ Object
Sets the custom X-SMTPAPI header after creating the email but before delivery.
-
#sendgrid_category(category) ⇒ Object
Call within mailer method to override the default value.
-
#sendgrid_disable(*options) ⇒ Object
Call within mailer method to remove one of the defaults.
-
#sendgrid_enable(*options) ⇒ Object
Call within mailer method to add an option not in the defaults.
-
#sendgrid_footer_text(texts) ⇒ Object
Call within mailer method to override the default value.
-
#sendgrid_recipients(emails) ⇒ Object
Call within mailer method to add an array of recipients.
-
#sendgrid_spamcheck_maxscore(score) ⇒ Object
Call within mailer method to override the default value.
-
#sendgrid_subscriptiontrack_text(texts) ⇒ Object
Call within mailer method to override the default value.
-
#sendgrid_substitute(placeholder, subs) ⇒ Object
Call within mailer method to add an array of substitions NOTE: you must ensure that the length of the substitions equals the length of the sendgrid_recipients.
Class Method Details
.included(base) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sendgrid.rb', line 15 def self.included(base) base.class_eval do class << self attr_accessor :default_sg_category, :default_sg_options, :default_subscriptiontrack_text, :default_footer_text, :default_spamcheck_score end attr_accessor :sg_category, :sg_options, :sg_disabled_options, :sg_recipients, :sg_substitutions, :subscriptiontrack_text, :footer_text, :spamcheck_score end base.extend(ClassMethods) end |
Instance Method Details
#create!(method_name, *parameters) ⇒ Object
Sets the custom X-SMTPAPI header after creating the email but before delivery
120 121 122 123 124 |
# File 'lib/sendgrid.rb', line 120 def create!(method_name, *parameters) super puts "SendGrid X-SMTPAPI: #{sendgrid_json_headers(mail)}" if Object.const_defined?("SENDGRID_DEBUG_OUTPUT") && SENDGRID_DEBUG_OUTPUT @mail['X-SMTPAPI'] = sendgrid_json_headers(mail) end |
#sendgrid_category(category) ⇒ Object
Call within mailer method to override the default value.
74 75 76 |
# File 'lib/sendgrid.rb', line 74 def sendgrid_category(category) @sg_category = category end |
#sendgrid_disable(*options) ⇒ Object
Call within mailer method to remove one of the defaults.
85 86 87 88 |
# File 'lib/sendgrid.rb', line 85 def sendgrid_disable(*) @sg_disabled_options = Array.new unless @sg_disabled_options .each { |option| @sg_disabled_options << option if VALID_OPTIONS.include?(option) } end |
#sendgrid_enable(*options) ⇒ Object
Call within mailer method to add an option not in the defaults.
79 80 81 82 |
# File 'lib/sendgrid.rb', line 79 def sendgrid_enable(*) @sg_options = Array.new unless @sg_options .each { |option| @sg_options << option if VALID_OPTIONS.include?(option) } end |
#sendgrid_footer_text(texts) ⇒ Object
Call within mailer method to override the default value.
110 111 112 |
# File 'lib/sendgrid.rb', line 110 def (texts) @footer_text = texts end |
#sendgrid_recipients(emails) ⇒ Object
Call within mailer method to add an array of recipients
91 92 93 94 |
# File 'lib/sendgrid.rb', line 91 def sendgrid_recipients(emails) @sg_recipients = Array.new unless @sg_recipients @sg_recipients = emails end |
#sendgrid_spamcheck_maxscore(score) ⇒ Object
Call within mailer method to override the default value.
115 116 117 |
# File 'lib/sendgrid.rb', line 115 def sendgrid_spamcheck_maxscore(score) @spamcheck_score = score end |
#sendgrid_subscriptiontrack_text(texts) ⇒ Object
Call within mailer method to override the default value.
105 106 107 |
# File 'lib/sendgrid.rb', line 105 def sendgrid_subscriptiontrack_text(texts) @subscriptiontrack_text = texts end |
#sendgrid_substitute(placeholder, subs) ⇒ Object
Call within mailer method to add an array of substitions NOTE: you must ensure that the length of the substitions equals the
length of the sendgrid_recipients.
99 100 101 102 |
# File 'lib/sendgrid.rb', line 99 def sendgrid_substitute(placeholder, subs) @sg_substitutions = Hash.new unless @sg_substitutions @sg_substitutions[placeholder] = subs end |