[ANN] Needle 1.2.0

J

Jamis Buck

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[ANN] Needle-Extras 1.0.0 4
[ANN] Needle 1.1.0 3
[ANN] Needle 0.9.0 0
[ANN] Needle 1.0.0 9
[ANN] Needle 0.5.0 0
[ANN] Needle 0.9.0 0
[ANN] Needle 0.6.0 0
Needle and Parameterized Services 13

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top