Class: Brightbytes::Sendgrid::Unsubscribe
- Inherits:
-
Object
- Object
- Brightbytes::Sendgrid::Unsubscribe
- Includes:
- SubstPattern
- Defined in:
- lib/brightbytes/sendgrid/unsubscribe.rb
Constant Summary
Constants included from SubstPattern
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#sendgrid ⇒ Object
readonly
Returns the value of attribute sendgrid.
Class Method Summary collapse
Instance Method Summary collapse
- #add_links ⇒ Object
-
#initialize(sendgrid, message) ⇒ Unsubscribe
constructor
A new instance of Unsubscribe.
Constructor Details
#initialize(sendgrid, message) ⇒ Unsubscribe
Returns a new instance of Unsubscribe.
20 21 22 |
# File 'lib/brightbytes/sendgrid/unsubscribe.rb', line 20 def initialize(sendgrid, ) @sendgrid, @message = sendgrid, end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
18 19 20 |
# File 'lib/brightbytes/sendgrid/unsubscribe.rb', line 18 def @message end |
#sendgrid ⇒ Object (readonly)
Returns the value of attribute sendgrid.
17 18 19 |
# File 'lib/brightbytes/sendgrid/unsubscribe.rb', line 17 def sendgrid @sendgrid end |
Class Method Details
.add_links(sendgrid, message) ⇒ Object
11 12 13 |
# File 'lib/brightbytes/sendgrid/unsubscribe.rb', line 11 def add_links(sendgrid, ) new(sendgrid, ).add_links end |
Instance Method Details
#add_links ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/brightbytes/sendgrid/unsubscribe.rb', line 24 def add_links return unless feature_active? if categories.present? sendgrid.section :unsubscribe_html_section, unsubscribe.html_link % key_to_tag(:unsubscribe_url) sendgrid.section :unsubscribe_text_section, unsubscribe.text_link % key_to_tag(:unsubscribe_url) emails.each do |email| sendgrid.add_substitute :unsubscribe_html, key_to_tag(:unsubscribe_html_section) sendgrid.add_substitute :unsubscribe_text, key_to_tag(:unsubscribe_text_section) sendgrid.add_substitute :unsubscribe_url, unsubscribe_url(email) end else sendgrid.add_substitute :unsubscribe_html, Array.new(emails.size, '') sendgrid.add_substitute :unsubscribe_text, Array.new(emails.size, '') sendgrid.add_substitute :unsubscribe_url, Array.new(emails.size, '') end end |