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.
[R] | default_priority | The default priority to use for elements of this type. |
[R] | name | The name of this element (may be nil). |
[R] | options | The hash of options that were given to this element. |
[R] | priority | The priority of this element, used to determine ordering. Higher ordered elements are invoked before lower-ordered elements. |
[R] | service_point | The service definition that this element belongs to. |
[RW] | succ | 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. |
- Comparable
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.
[ show source ]
# File lib/needle/pipeline/element.rb, line 59 59: def initialize( point, name=nil, priority=nil, options={} ) 60: @service_point = point 61: @name, @priority = name, ( priority || self.class.default_priority ) 62: @options = options 63: initialize_element 64: end
Set the default priority for elements of this type. Subclasses may use this method to set their default priority.
[ show source ]
# File lib/needle/pipeline/element.rb, line 49 49: def set_default_priority( priority ) 50: @default_priority = priority 51: end
Orders elements by their priority.
[ show source ]
# File lib/needle/pipeline/element.rb, line 72 72: def <=>( element ) 73: priority <=> element.priority 74: end
Alias for call
Invoke this element’s logic.
[ show source ]
# File lib/needle/pipeline/element.rb, line 77 77: def call( *args ) 78: raise NotImplementedError 79: end
Invoked by the constructor to perform any subclass-specific initialization logic.
[ show source ]
# File lib/needle/pipeline/element.rb, line 68 68: def initialize_element 69: end
Invoked by Pipeline::Collection#reset!. Subclasses of Element that save any kind of state should override this method to clear that state on demand.
[ show source ]
# File lib/needle/pipeline/element.rb, line 84 84: def reset! 85: end