Class: Needle::Pipeline::Collection

Class | Needle::Pipeline::Collection
In: | lib/needle/pipeline/collection.rb
Parent: | Object

Represents a collection of pipeline elements. Elements may be added to the pipeline, and then returned as a single object representing the chain of pipeline elements.

### Methods

add chain_to get new reset!

### Classes and Modules

Class Needle::Pipeline::Collection::BlockElement

### Public Class methods

new( service_point )

Create a new pipeline element collection, initially empty.

### Public Instance methods

add( *args, &block )

Add a new pipeline element to this collection. If the first parameter is a symbol or a string, it is taken to be the name of the element to add. If no explicit implementation is given, then the implementation is looked up in the `:pipeline_elements` service, using the given name.

After the first parameter, if the next parameter is numeric, it is taken to mean the priority of the element. This overrides whatever default priority is given for the selected element.

If the next parameter responds to the `:new` message, it is taken to be an explicit implementation of the element. This is only valid if a block is not given. If a block is given, then it is always taken to be the implementation of the element.

If the last parameter is a Hash, it is taken to be a map of options that should be passed to the element when it is instantiated.

This returns `self`, so that add calls may be chained.

chain_to( block )

Builds a linked list of the elements, with the last element being the block (or block-like) object given by the parameter. Higher-priority elements will be closer to the head of the list.

get( name )

Returns the first pipeline element with the given name, or `nil` if no such element exists.

reset!( *args )

Clears the state for each named element. If no elements are named, all elements are cleared.

[Validate]