Class: SimplePipeline
- Inherits:
-
Object
- Object
- SimplePipeline
- Defined in:
- lib/simple_pipeline.rb,
lib/simple_pipeline/timeout.rb,
lib/simple_pipeline/version.rb
Defined Under Namespace
Modules: Timeout
Constant Summary collapse
- VERSION =
"0.0.5"
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #add(pipe, params = {}) ⇒ Object
-
#initialize ⇒ SimplePipeline
constructor
A new instance of SimplePipeline.
- #process(payload) ⇒ Object
- #size ⇒ Object (also: #length)
Constructor Details
#initialize ⇒ SimplePipeline
Returns a new instance of SimplePipeline.
9 10 11 12 13 |
# File 'lib/simple_pipeline.rb', line 9 def initialize @pipe_order = [] @pipe_config = {} @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/simple_pipeline.rb', line 7 def errors @errors end |
Instance Method Details
#add(pipe, params = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/simple_pipeline.rb', line 15 def add (pipe, params = {}) process_method = params[:process_method] || :process begin raise ArgumentError, "invalid pipe - incorrect number of arguments for #{process_method}() method (should be 1)" unless pipe.class.instance_method(process_method).arity == 1 rescue NameError raise ArgumentError, "invalid pipe - #{process_method}() method not found" end @pipe_order << pipe @pipe_config[pipe] = params return pipe end |
#process(payload) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/simple_pipeline.rb', line 34 def process (payload) @pipe_order.each do |pipe| begin invoke_process_with_timeout(pipe, payload, get_timeout(pipe)) rescue raise $! unless continue_on_error?($!, pipe) @errors << $! end end end |
#size ⇒ Object Also known as: length
30 31 32 |
# File 'lib/simple_pipeline.rb', line 30 def size return @pipe_order.size end |