Module: ProtoProcessor::Strategy
- Defined in:
- lib/proto_processor/strategy.rb
Instance Method Summary collapse
- #current_input ⇒ Object
- #process ⇒ Object
- #report ⇒ Object
- #run {|report| ... } ⇒ Object
-
#run_task(task_class, options = nil, &block) ⇒ Object
Run a task and update input and report (but don’t update options) If passed and array of options, run task for each option hash.
- #runner ⇒ Object
- #with_input(input) ⇒ Object
Instance Method Details
#current_input ⇒ Object
32 33 34 |
# File 'lib/proto_processor/strategy.rb', line 32 def current_input @current_input ||= '' end |
#process ⇒ Object
24 25 26 |
# File 'lib/proto_processor/strategy.rb', line 24 def process raise NotImplementedError, "You must implement #process in your strategies" end |
#report ⇒ Object
3 4 5 |
# File 'lib/proto_processor/strategy.rb', line 3 def report @report ||= ProtoProcessor::Report.new end |
#run {|report| ... } ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/proto_processor/strategy.rb', line 11 def run begin ProtoProcessor.logger.info "Running strategy #{self.class.name}" process rescue StandardError => e report.fail!(e) ProtoProcessor.logger.error e.class.name ProtoProcessor.logger.debug e. + "\n" + e.backtrace.join("\n") end yield report if block_given? report end |
#run_task(task_class, options = nil, &block) ⇒ Object
Run a task and update input and report (but don’t update options)
If passed and array of options, run task for each option hash
39 40 41 42 |
# File 'lib/proto_processor/strategy.rb', line 39 def run_task(task_class, = nil, &block) return false if .nil? run_task_chain([*task_class], , &block) end |
#runner ⇒ Object
7 8 9 |
# File 'lib/proto_processor/strategy.rb', line 7 def runner @task_runner ||= ProtoProcessor::TaskRunner.new(report) end |
#with_input(input) ⇒ Object
28 29 30 |
# File 'lib/proto_processor/strategy.rb', line 28 def with_input(input) @current_input = input#.dup # dup so we don't overwrite passed input later on end |