Class | Needle::DefinitionContext |
In: |
lib/needle/definition-context.rb
|
Parent: | Object |
This class is used by the Container#define! and Container#namespace! methods to allow an instance_eval‘d block to create new service points simply by invoking imaginary methods. It is basically an empty shell, with almost all of the builtin methods removed from it. (This allows services like "hash" and "print" to be defined, where they would normally conflict with the Kernel methods of the same name.)
Create a new DefinitionContext that wraps the given container. All operations performed on this context will be delegated to the container.
Any method invocation with no block and no parameters is interpreted to be a service reference on the wrapped container, and delegates to Container#[]. If the block is not given but the args are not empty, a NoMethodError will be raised.
If a block is given, this delegates to Container#register, leaving all parameters in place.
Delegate to Container#use on the current container, but yields the definition context instead of the container.
Delegate to Container#use! on the current container, but yields the definition context instead of the container.