Sha256: cfbaf13e77e4edcd88481b516f5b5f956cf34908740e2791b8da86e53abd6d5c
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
= syringe A very lightweight dependency injection container for Ruby. It born from a real need in one of my current projects (at Locaweb). I'm only scratching our itch. If you have the same itch, join us! ==== Special Thanks Hey Jim Weirich, thanks for initial code and inspiration. You are the man! http://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionInRuby.rdoc == Install gem install syringe --pre -s http://gemcutter.org == Examples ==== First example with taste of service locator pattern # on application bootstrap container = Syringe::Container.new container.register(:service_uri) { |container| 'http://services.syringe.org/api' } container.register(:service_consumer) { |container| ServiceConsumer.new(container[:service_uri]) } ... # anywhere in the code puts container[:service_uri] # http://services.syringe.org/api puts container.service_uri # http://services.syringe.org/api ==== Second example with the best taste of dependency injection # on application bootstrap default_container = Syringe::Container.default default_container.register(:service_uri) { |container| 'http://services.syringe.org/api' } ... # in some class class ServiceConsumer inject :service_uri # it will create a new method and instance variable with that name end ... # anywhere in the code service_consumer = ServiceConsumer.new puts service_consumer.service_uri # 'http://services.syringe.org/api' == See more on http://github.com/leandrosilva/syringe/tree/master/spec == Copyright Copyright (c) 2010 Leandro Silva (CodeZone) <leandrodoze@gmail.com>. See LICENSE for details.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
syringe-0.0.1.pre | README.rdoc |