Sha256: 28372c1822834c23b47cacc13977458d3b03e3f3b31760cb29c04c641701c0e5
Contents?: true
Size: 1.29 KB
Versions: 4
Compression:
Stored size: 1.29 KB
Contents
Creating a registry is as simple as calling @Needle::Registry.new@. This will give you a new registry object, bootstrapped to contain a few general services. <pre> require 'needle' registry = Needle::Registry.new </pre> Once you have the reference to the registry, you can register services with it, create new namespaces in it, and so forth. Alternatively, you can pass a block to @#new@: <pre> registry = Needle::Registry.new do |r| ... end </pre> The parameter to the block will be a reference to the registry. This allows you to register services with the registry as soon as it is created. Another convenience method is @#define!@: <pre> registry = Needle::Registry.define! do ... end </pre> This block accepts no parameters, and evaluates the block as if it were passed to @Registry#define!@ (see below). There can be problems with using @define!@, however, since it uses @instance_eval@ to evaluate the block within the context of another object. If you find yourself running into scoping issues, you might want to consider using @#define@: <pre> registry = Needle::Registry.define do |b| ... end </pre> This block accepts a single parameter--a "builder" object to aid in registering services--and evaluates the block as if it were passed to @Registry#define@ (see below).
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
needle-1.0.0 | doc/manual/parts/02_creating.txt |
needle-1.1.0 | doc/manual/parts/02_creating.txt |
needle-1.2.0 | doc/manual/parts/02_creating.txt |
needle-0.9.0 | doc/manual/parts/02_creating.txt |