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.)

Methods

Public Class methods

Create a new DefinitionContext that wraps the given container. All operations performed on this context will be delegated to the container.

Public Instance methods

Delegates to Container#has_key?.

Delegates to Container#knows_key?.

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.

namespace!( *parms, &block )

Alias for namespace_define!

Delegate to Container#define on the new namespace.

Delegate to Container#require on the current container.

A way to access the container reference being operated on from within the context.

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.

[Validate]