### Home Classes Methods

### In Files

- lib/needle/interceptor.rb

### Parent

Object

### Methods

- ::new
- #new
- #process

### Files

- README

### Class/Module Index

Quicksearch

- Needle
- Needle::Bug
- Needle::Container
- Needle::DefinitionContext
- Needle::IncludeExclude
- Needle::Interceptor
- Needle::Interceptor::DynamicInterceptor
- Needle::InterceptorChainBuilder
- Needle::InterceptorChainBuilder::InterceptedServiceProxy
- Needle::InterceptorChainBuilder::InterceptorChainElement
- Needle::InterceptorChainBuilder::ProxyObjectChainElement
- Needle::InterceptorConfigurationError
- Needle::Lifecycle
- Needle::Lifecycle::Deferred
- Needle::Lifecycle::Initialize
- Needle::Lifecycle::Multiton
- Needle::Lifecycle::Proxy
- Needle::Lifecycle::Singleton
- Needle::Lifecycle::Threaded
- Needle::LogFactory
- Needle::Logger
- Needle::LoggingInterceptor
- Needle::NeedleError
- Needle::Pipeline
- Needle::Pipeline::Collection
- Needle::Pipeline::Collection::BlockElement
- Needle::Pipeline::Element
- Needle::Pipeline::InterceptorElement
- Needle::QueryableMutex
- Needle::Registry
- Needle::ServiceNotFound
- Needle::ServicePoint
- Needle::Version

No matching classes.

# Needle::Interceptor::DynamicInterceptor

This is the wrapper for on-the-fly interceptors that have been created via Interceptor#doing. The callback registered with Interceptor#doing gets wrapped by an instance of this class, to comply with the interface required by InterceptorChainBuilder.

This class should rarely (if ever) be instantiated directly. Instead, using the Interceptor#doing method to create dynamic interceptors.

### Public Class Methods

new( callback ) click to toggle source

Create a new DynamicInterceptor instance that wraps the given callback.

    # File lib/needle/interceptor.rb, line 48
    def initialize( callback )
      @callback = callback
    end

### Public Instance Methods

new( point, opts ) click to toggle source

This method is a concession to the required interceptor factory interface. It should return the new interceptor, configured to be attached to the given service point, and with the given options. It will always return `self`.

    # File lib/needle/interceptor.rb, line 56
    def new( point, opts )
      @point = point
      @options = opts
      self
    end

process( chain, context ) click to toggle source

Process this link in the interceptor chain. This will invoke the wrapped callback, passing in the chain and context parameters. Before invoking the callback, the options and service point references that were given in new are assigned to context data members (so they can be referenced inside the callback).

    # File lib/needle/interceptor.rb, line 67
    def process( chain, context )
      context.data[:options] = @options
      context.data[:point] = @point
      @callback.call( chain, context )
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.