Class: SimplePipeline
- Inherits:
-
Object
- Object
- SimplePipeline
- Defined in:
- lib/simple_pipeline.rb,
lib/simple_pipeline/timeout.rb,
lib/simple_pipeline/version.rb,
lib/simple_pipeline/validation.rb
Defined Under Namespace
Modules: Timeout, Validation
Constant Summary collapse
- VERSION =
"0.0.6"
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #add(pipe, options = {}) ⇒ 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.
10 11 12 13 14 |
# File 'lib/simple_pipeline.rb', line 10 def initialize @pipe_order = [] @pipe_options = {} @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/simple_pipeline.rb', line 8 def errors @errors end |
Instance Method Details
#add(pipe, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/simple_pipeline.rb', line 16 def add (pipe, = {}) process_method = [: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_options[pipe] = return pipe end |
#process(payload) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/simple_pipeline.rb', line 35 def process (payload) @errors.clear @pipe_order.each do |pipe| begin validate_payload(pipe, payload) 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
31 32 33 |
# File 'lib/simple_pipeline.rb', line 31 def size return @pipe_order.size end |