Class: MandrillDm::DeliveryMethod
- Inherits:
-
Object
- Object
- MandrillDm::DeliveryMethod
- Defined in:
- lib/mandrill_dm/delivery_method.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
-
#deliver!(mail) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize.
-
#initialize(options = {}) ⇒ DeliveryMethod
constructor
A new instance of DeliveryMethod.
Constructor Details
#initialize(options = {}) ⇒ DeliveryMethod
Returns a new instance of DeliveryMethod.
5 6 7 8 9 |
# File 'lib/mandrill_dm/delivery_method.rb', line 5 def initialize( = {}) @settings = { api_key: MandrillDm.configuration.api_key }.merge!() end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/mandrill_dm/delivery_method.rb', line 3 def response @response end |
#settings ⇒ Object
Returns the value of attribute settings.
3 4 5 |
# File 'lib/mandrill_dm/delivery_method.rb', line 3 def settings @settings end |
Instance Method Details
#deliver!(mail) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mandrill_dm/delivery_method.rb', line 13 def deliver!(mail) logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT) logger.error '!!! MIGRATE from Mandrill IMMEDIATELY: https://github.com/kshnurov/mandrill_dm/blob/master/MIGRATE' mandrill_api = Mandrill::API.new(settings[:api_key]) = Message.new(mail) @response = if .template mandrill_api..send_template( .template, .template_content, .to_json, MandrillDm.configuration.async, .ip_pool || MandrillDm.configuration.ip_pool, .send_at ) else mandrill_api..send( .to_json, MandrillDm.configuration.async, .ip_pool || MandrillDm.configuration.ip_pool, .send_at ) end end |