From 0136d7c96fccc5f99d5aefc98510d0383df3fd59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Horion?= Date: Mon, 19 May 2014 10:59:27 -0700 Subject: [PATCH] update the Readme wrote an exemple with the "with()" --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 8168e46..dca514a 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,18 @@ mail.deliver some_message mail.use :null # switch back to the null implementation. ``` +Sometimes you'll want to use an implementation for the duration of a block: + +``` +mailer = Mailer.new +mailer.register :snail_mail, SnailMail.new + +mailer.with(:smtp) do |smtp_mailer| + smtp_mailer.deliver some_message +end + +mailer.deliver some_message_with_snail_mail +``` These objects are useful when you have an interaction that needs to happen but implementations can vary widely. You can also use this