Class: Superbolt::Processor
- Inherits:
-
Object
- Object
- Superbolt::Processor
- Defined in:
- lib/superbolt/processor.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Instance Method Summary collapse
- #finish! ⇒ Object
-
#initialize(message, logger, &block) ⇒ Processor
constructor
A new instance of Processor.
- #perform ⇒ Object
- #start! ⇒ Object
Constructor Details
#initialize(message, logger, &block) ⇒ Processor
Returns a new instance of Processor.
6 7 8 9 10 |
# File 'lib/superbolt/processor.rb', line 6 def initialize(, logger, &block) @message = @logger = logger @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/superbolt/processor.rb', line 3 def block @block end |
#exception ⇒ Object
Returns the value of attribute exception.
4 5 6 |
# File 'lib/superbolt/processor.rb', line 4 def exception @exception end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/superbolt/processor.rb', line 3 def logger @logger end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/superbolt/processor.rb', line 3 def @message end |
#start_time ⇒ Object
Returns the value of attribute start_time.
4 5 6 |
# File 'lib/superbolt/processor.rb', line 4 def start_time @start_time end |
Instance Method Details
#finish! ⇒ Object
28 29 30 31 |
# File 'lib/superbolt/processor.rb', line 28 def finish! end_time = Time.now logger.info "[#{end_time}] Finished message: #{.parse} in #{end_time - start_time} seconds" end |
#perform ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/superbolt/processor.rb', line 12 def perform start! block.call(.parse, logger) finish! true rescue Exception => e self.exception = e logger.error("#{e.}\n#{e.backtrace}") false end |
#start! ⇒ Object
23 24 25 26 |
# File 'lib/superbolt/processor.rb', line 23 def start! self.start_time = Time.now logger.info "[#{start_time}] Processing message: #{.parse}" end |