Class: Serbea::Pipeline
- Inherits:
-
Object
- Object
- Serbea::Pipeline
- Defined in:
- lib/serbea/pipeline.rb
Class Method Summary collapse
Instance Method Summary collapse
- #filter(sym, *aargs) ⇒ Object
-
#initialize(context, value) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #raise_on_missing_filters ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(context, value) ⇒ Pipeline
Returns a new instance of Pipeline.
13 14 15 16 |
# File 'lib/serbea/pipeline.rb', line 13 def initialize(context, value) @context = context @value = value end |
Class Method Details
.output_processor ⇒ Object
6 7 8 9 10 11 |
# File 'lib/serbea/pipeline.rb', line 6 def self.output_processor @output_processor ||= lambda do |input| # no-op input end end |
.output_processor=(processor) ⇒ Object
3 4 5 |
# File 'lib/serbea/pipeline.rb', line 3 def self.output_processor=(processor) @output_processor = processor end |
Instance Method Details
#filter(sym, *aargs) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/serbea/pipeline.rb', line 18 def filter(sym, *aargs) if @value.respond_to?(sym) @value = @value.send(sym, *aargs) elsif @context.respond_to?(sym) @value = @context.send(sym, @value, *aargs) else "Serbea warning: Filter not found: #{sym}".tap do |warning| raise_on_missing_filters ? raise(warning) : puts(warning) end end self end |
#raise_on_missing_filters ⇒ Object
36 |
# File 'lib/serbea/pipeline.rb', line 36 def raise_on_missing_filters; false; end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/serbea/pipeline.rb', line 32 def to_s self.class.output_processor.call @value.to_s end |