devise
https://github.com/plataformatec/devise
Ruby
Flexible authentication solution for Rails with Warden.
Mail::Message#delivery_handler
If you assign a delivery handler, mail will call :deliver_mail on the
object you assign to delivery_handler, it will pass itself as the
single argument.
If you define a delivery_handler, then you are responsible for the
following actions in the delivery cycle:
* Appending the mail object to Mail.deliveries as you see fit.
* Checking the mail.perform_deliveries flag to decide if you should
actually call :deliver! the mail object or not.
* Checking the mail.raise_delivery_errors flag to decide if you
should raise delivery errors if they occur.
* Actually calling :deliver! (with the bang) on the mail object to
get it to deliver itself.
A simplest implementation of a delivery_handler would be
class MyObject
def initialize
@mail = Mail.new('To: [email protected]')
@mail.delivery_handler = self
end
attr_accessor :mail
def deliver_mail(mail)
yield
end
end
Then doing:
obj = MyObject.new
obj.mail.deliver
Would cause Mail to call obj.deliver_mail passing itself as a parameter,
which then can just yield and let Mail do its own private do_delivery
method.Edit
git clone [email protected]:plataformatec/devise.git
cd devise
open
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Mail--Message-delivery_handler-for-pr
# Commit to gitgit add git commit -m "better docs for Mail::Message#delivery_handler"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Mail--Message-delivery_handler-for-pr
hub pull-request
# Celebrate!