This file is indexed.

/usr/share/doc/libneedle-ruby1.8/doc/manual/parts/customizing_contexts.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
A _definition context_ is used when registering services using any of the @#define@ interfaces. For example, @Container#define@ yields an instance of a definition context to the given block, and @Container#define!@ uses the block in an @instance_eval@ on a definition context.

The default implementation used for definition contexts is defined by the @:definition_context_factory@ service. By default, this service returns @Needle::DefinitionContext@, but you can specify your own definition context implementations by overriding this service. In fact, each namespace could have its own definition context implementation, if needed.

Consider the following contrived example, where you want to provide a convenient way to register services of type Hash.

{{{lang=ruby,number=true,caption=Custom DefinitionContext example
class MyDefinitionContext < Needle::DefinitionContext
  def register_hash( name, opts={} )
    this_container.register( name, opts ) { Hash.new }
  end
end

reg = Needle::Registry.new
reg.register( :definition_context_factory ) { MyDefinitionContext }

reg.define do |b|
  b.register_hash( :test1 )
  b.register_hash( :test2 )
end

reg.test1[:key] = "value"
reg.test2[:foo] = "bar"
}}}