Why Singleton Classes for Connectors

6 views
Skip to first unread message

Schorsch

unread,
Dec 10, 2009, 5:49:24 AM12/10/09
to Ruby's Mail Discussion Group
Maybe i still lack some ruby programming knowledge, but why do you use
singletons for the smtp/pop connectors. Im running a rails based
webservice and want my users to provide their own mail settings.
Now i dont know how to achive this or if its even possible with
mail.rb.

Mikel Lindsaar

unread,
Dec 10, 2009, 10:45:36 PM12/10/09
to mail...@googlegroups.com
Seemed like a good idea at the time.

Although your use case shows a bit different I suppose.

The biggest advantage with signletons is we can set the config once, at load time and just do "Mail.deliver"

Mikel

Schorsch

unread,
Dec 11, 2009, 7:52:03 AM12/11/09
to Ruby's Mail Discussion Group
Ok, than my assumptions where right. I thought there might be some
hidden mail request problems when opening a bunch of connections from
within a couple of threads.
The singleton behaviour also got me darn stuck on actionmailer(tmail).
In the case of system mails and most other rails-email use-cases the
singleton way is indeed pretty elegant. But i had a couple of projects
(f.ex a redmine ticket mail plugin) where this lead to thoughts about
writing an own mail lib .. which is crazy just for the connection
settings. It therefore prevented us from implementing some nice
flexible mail stuff and in one case we even went with a C-based pim
server(Citadell) just to parse mails .... really weird

Now with the possibility to fetch mails, the problem grows even
bigger.

Reading mail.rb code i had the idea to implement an own delivery
method. But the configuration class above it, is also bound to one
instance.

Im not so deep into mail that i could program a suggestion. To get rid
of this straitjacket, there should be some kind of disctinction
between the global default singleton settings and others provided at
runtime,

thanks for your time spending a thought on this :-)

george


On Dec 11, 4:45 am, Mikel Lindsaar <raasd...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages