Module: Cuniculus::CuniculusMethods
- Included in:
- Cuniculus
- Defined in:
- lib/cuniculus/core.rb
Overview
Core Cuniculus methods
Instance Method Summary collapse
-
#convert_exception_class(exception, klass) ⇒ Cuniculus::Error
Convert the input ‘exception` to the given class.
-
#dump_job(job) ⇒ Object
Serializes a Ruby object for publishing to RabbitMQ.
-
#load_job(rmq_msg) ⇒ Object
Convert a RabbitMQ message into Ruby object for processing.
- #mark_time ⇒ Object
Instance Method Details
#convert_exception_class(exception, klass) ⇒ Cuniculus::Error
Convert the input ‘exception` to the given class. The given class should be Error or a subclass. Returns an instance of `klass` with the message and backtrace of `exception`.
29 30 31 32 33 34 35 36 |
# File 'lib/cuniculus/core.rb', line 29 def convert_exception_class(exception, klass) return exception if exception.is_a?(klass) e = klass.new("#{exception.class}: #{exception.}") e.wrapped_exception = exception e.set_backtrace(exception.backtrace) e end |
#dump_job(job) ⇒ Object
Serializes a Ruby object for publishing to RabbitMQ.
17 18 19 |
# File 'lib/cuniculus/core.rb', line 17 def dump_job(job) ::JSON.dump(job) end |
#load_job(rmq_msg) ⇒ Object
Convert a RabbitMQ message into Ruby object for processing.
12 13 14 |
# File 'lib/cuniculus/core.rb', line 12 def load_job(rmq_msg) ::JSON.parse(rmq_msg) end |
#mark_time ⇒ Object
38 39 40 |
# File 'lib/cuniculus/core.rb', line 38 def mark_time Process.clock_gettime(Process::CLOCK_MONOTONIC) end |