Class: Mailchimp::StsDeliveryHandler
- Inherits:
-
Object
- Object
- Mailchimp::StsDeliveryHandler
- Defined in:
- lib/mailchimp/handlers/sts_delivery_handler.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #deliver!(message) ⇒ Object
-
#initialize(options) ⇒ StsDeliveryHandler
constructor
A new instance of StsDeliveryHandler.
Constructor Details
#initialize(options) ⇒ StsDeliveryHandler
Returns a new instance of StsDeliveryHandler.
7 8 9 |
# File 'lib/mailchimp/handlers/sts_delivery_handler.rb', line 7 def initialize self.settings = {:track_opens => true, :track_clicks => true}.merge() end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
5 6 7 |
# File 'lib/mailchimp/handlers/sts_delivery_handler.rb', line 5 def settings @settings end |
Instance Method Details
#deliver!(message) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mailchimp/handlers/sts_delivery_handler.rb', line 11 def deliver! = { :track_opens => settings[:track_opens], :track_clicks => settings[:track_clicks], :message => { :subject => .subject, :from_name => settings[:from_name], :from_email => .from.first, :to_email => .to } } mime_types = { :html => "text/html", :text => "text/plain" } get_content_for = lambda do |format| content = .send(:"#{format}_part") content ||= if .content_type =~ %r{#{mime_types[format]}} content end [:html, :text].each do |format| content = get_content_for.call(format) [:message][format] = content.body if content end [:tags] = settings[:tags] if settings[:tags] STS.new(settings[:api_key]).send_email() end |