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

has_key? intercept knows_key? method_missing namespace namespace! namespace_define namespace_define! new require this_container use use!

### Public Class methods

new( container )

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

### Public Instance methods

has_key?( name )

Delegates to Container#has_key?.

intercept( name )

Delegate to Container#intercept.

knows_key?( name )

Delegates to Container#knows_key?.

method_missing( sym, *args, &block )

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 )

Delegate to Container#namespace.

namespace!( *parms, &block )

Alias for namespace_define!

namespace_define( *parms, &block )

Delegate to Container#define on the new namespace.

namespace_define!( *parms, &block )

Delegate to Container#namespace_define!.

require( *parms )

Delegate to Container#require on the current container.

this_container()

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

use( opts, &block )

Delegate to Container#use on the current container, but yields the definition context instead of the container.

use!( opts ) {|self| ...}

Delegate to Container#use! on the current container, but yields the definition context instead of the container.

[Validate]