sendgrid-rails icon indicating copy to clipboard operation
sendgrid-rails copied to clipboard

Have class-methods for options rather than per-method

Open nuclearspike opened this issue 8 years ago • 1 comments

Unless I'm missing it, it would be very handy to be able to set some of these options at the controller level rather than for each method like the way the (apparently abandoned) 'sendgrid' gem does it. Then you can override the option in the methods if you want. I'd like to set up opentracking for everything, for example.

class MyMailer < ActionMailer::Base
  include SendGrid
  sendgrid_category :use_subject_lines
  sendgrid_enable   :ganalytics, :opentrack
  sendgrid_unique_args :key1 => "value1", :key2 => "value2"

  def welcome_message(user)
    sendgrid_category "Welcome"
    sendgrid_unique_args :key2 => "newvalue2", :key3 => "value3"
    mail :to => user.email, :subject => "Welcome #{user.name} :-)"
  end

  def goodbye_message(user)
    sendgrid_disable :ganalytics
    mail :to => user.email, :subject => "Fare thee well :-("
  end
end

nuclearspike avatar Jul 12 '16 08:07 nuclearspike

Though this is a nice DSL, I prefer to keep things simple. Who ever needs it may easily extend their own classes.

paveltyk avatar Jul 12 '16 09:07 paveltyk