[ANN] Needle 1.2.0

Here, in keeping with my every-Thursday release schedule, is the latest and greatest Needle.

Needle, for those of you that have missed the hype, is a dependency injection container for Ruby, employing many of Ruby's best idioms.

   Project page: http://rubyforge.org/projects/needle
   User Manual: http://needle.rubyforge.org
   API Docs: http://needle.rubyforge.org/api
   FAQ Document: http://needle.rubyforge.org/faq.html
   Needle Wiki: http://needle.rubyforge.org/wiki/wiki.pl

Version 1.2 introduces several new features, and fixes a few minor bugs:

   * Parameterized services. You can now specify parameters when requesting a service, and (unless the service model in use is incompatible with extra parameters, like singleton) those parameters will be passed to the constructor block of the service. This allows, for example:

   * Multiton services. You can use a multiton service model when registering a service, and then every unique set of parameters used when requesting a service will result in the caching of the returned object, to be reused whenever the same parameter set is given.

   * :log_for is a new parameterized service that provides more convenient access to a registry's log factory. Just pass the name of the log you want (or the service point to obtain a log for) to the :log_for service when requesting it:

       log1 = c.log_for( "foo" )
       log2 = c.log_for( point )

   * DefinitionContext now passes all unknown messages through to its container, making it possible to access parameterized services via the definition context.

   * Updated the manual and FAQ documents to include the new features described above.

   * Fixed several bugs and documentation typos.

Special thanks go to Christian Neukirchen for getting me to start thinking about parameterized services, Joel VanderWerf for suggesting multiton services (and demonstrating that my original solution to the parameterization problem was insufficient in this case), and Daigo Moriwaki for some great last-minute bug reports.

Enjoy!

P.S. A side note, for those that are interested. I actually implemented support for private and protected services, and then ripped the implementation out again. It resulted in a (minimum) 30% increase in overhead when requesting any service, which was unacceptable, especially since the private/protected feature would be infrequently used. If you are interested in seeing the implementation, look at the Needle CVS sources, under the "service_visibility" tag. If anyone REALLY wants this feature, I'm willing to entertain patches that do not negatively impact the common case (public services).

···

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis