Class: Needle::Pipeline::Element

### Home Classes Methods

### In Files

- lib/needle/pipeline/element.rb

### Parent

Object

### Methods

- ::new
- ::set_default_priority
- #<=>
- #[]
- #call
- #initialize_element
- #reset!

### Included Modules

- Comparable

### 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::Pipeline::Element

The base class of instantiation pipeline elements. All subclasses MUST implement is the call method, to define the logic that instances of that pipeline element should perform when invoked.

### Attributes

default_priority[R]

The default priority to use for elements of this type.

name[R]

The name of this element (may be `nil`).

options[R]

The hash of options that were given to this element.

priority[R]

The priority of this element, used to determine ordering. Higher ordered elements are invoked before lower-ordered elements.

service_point[R]

The service definition that this element belongs to.

succ[RW]

The next element in the chain. This value is only valid during pipeline execution--its value should not be relied upon at any other time.

### Public Class Methods

new( point, name=nil, priority=nil, options={} ) click to toggle source

Create a new element instance with the given name and priority. This will call initialize_element, so that subclasses only need to implement that method if they have any initialization logic to perform.

    # File lib/needle/pipeline/element.rb, line 59
    def initialize( point, name=nil, priority=nil, options={} )
      @service_point = point
      @name, @priority = name, ( priority || self.class.default_priority )
      @options = options
      initialize_element
    end

set_default_priority( priority ) click to toggle source

Set the default priority for elements of this type. Subclasses may use this method to set their default priority.

    # File lib/needle/pipeline/element.rb, line 49
    def set_default_priority( priority )
      @default_priority = priority
    end

### Public Instance Methods

<=>( element ) click to toggle source

Orders elements by their priority.

    # File lib/needle/pipeline/element.rb, line 72
    def <=>( element )
      priority <=> element.priority
    end

[]( *args ) click to toggle source
Alias for: call
call( *args ) click to toggle source

Invoke this element's logic.

    # File lib/needle/pipeline/element.rb, line 77
    def call( *args )
      raise NotImplementedError
    end

Also aliased as: []
initialize_element() click to toggle source

Invoked by the constructor to perform any subclass-specific initialization logic.

    # File lib/needle/pipeline/element.rb, line 68
    def initialize_element
    end

reset!() click to toggle source

Invoked by Pipeline::Collection#reset!. Subclasses of Element that save any kind of state should override this method to clear that state on demand.

    # File lib/needle/pipeline/element.rb, line 84
    def reset!
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.