Class: Brightbytes::Sendgrid::Unsubscribe
- Inherits:
-
Object
- Object
- Brightbytes::Sendgrid::Unsubscribe
- Defined in:
- lib/brightbytes/sendgrid/unsubscribe.rb
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.
19 20 21 |
# File 'lib/brightbytes/sendgrid/unsubscribe.rb', line 19 def initialize(sendgrid, ) @sendgrid, = sendgrid, end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
17 18 19 |
# File 'lib/brightbytes/sendgrid/unsubscribe.rb', line 17 def end |
#sendgrid ⇒ Object (readonly)
Returns the value of attribute sendgrid.
16 17 18 |
# File 'lib/brightbytes/sendgrid/unsubscribe.rb', line 16 def sendgrid @sendgrid end |
Class Method Details
.add_links(sendgrid, message) ⇒ Object
10 11 12 |
# File 'lib/brightbytes/sendgrid/unsubscribe.rb', line 10 def add_links(sendgrid, ) new(sendgrid, ).add_links end |
Instance Method Details
#add_links ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/brightbytes/sendgrid/unsubscribe.rb', line 23 def add_links return unless feature_active? if categories.present? sendgrid.section :unsubscribe_html_section, "#{unsubscribe.html_message} <a href=\"{{unsubscribe_url}}\" rel=\"nofollow\">#{unsubscribe.link_text}</a>" sendgrid.section :unsubscribe_text_section, "#{unsubscribe.text_message} {{unsubscribe_url}}" emails.each do |email| sendgrid.add_substitute :unsubscribe_html, "{{unsubscribe_html_section}}" sendgrid.add_substitute :unsubscribe_text, "{{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 |