跳至内容 跳至搜索

用于创建和包装传递行为的帮助器,由 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 52
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