跳到內容 跳到搜尋

有助於建立與封裝傳送行為的 Helper,由 DeliveryMethods 使用。

方法
A

執行個體公開的方法

add_delivery_method(symbol, klass, default_options = {})

透過使用指定的符號作為別名及提供的預設選項,新增使用指定類別的新傳送方法。

add_delivery_method :sendmail, Mail::Sendmail,
  location:  '/usr/sbin/sendmail',
  arguments: %w[ -i ]
# File actionmailer/lib/action_mailer/delivery_methods.rb, line 51
def add_delivery_method(symbol, klass, default_options = {})
  class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings")
  public_send(:"#{symbol}_settings=", default_options)
  self.delivery_methods = delivery_methods.merge(symbol.to_sym => klass).freeze
end