/usr/share/doc/libneedle-ruby1.8/doc/manual/parts/02_creating.txt is in libneedle-ruby1.8 1.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 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.
{{{lang=ruby,number=true,caption=Creating a registry
require 'needle'
registry = Needle::Registry.new
}}}
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@:
{{{lang=ruby,number=true,caption=Creating a registry with a block
registry = Needle::Registry.new do |r|
...
end
}}}
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!@:
{{{lang=ruby,number=true,caption=Creating a registry with #define!
registry = Needle::Registry.define! do
...
end
}}}
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@:
{{{lang=ruby,number=true,caption=Creating a registry with #define
registry = Needle::Registry.define do |b|
...
end
}}}
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).
|