module Cuniculus::CuniculusMethods

Core Cuniculus methods

Public Instance Methods

convert_exception_class(exception, klass) click to toggle source

Convert the input `exception` to the given class. The given class should be {Cuniculus::Error} or a subclass. Returns an instance of `klass` with the message and backtrace of `exception`.

@param exception [Exception] The exception being wrapped @param klass [Cuniculus::Error] The subclass of `Cuniculus::Error`

@return [Cuniculus::Error] An instance of the input `Cuniculus::Error`

   # File lib/cuniculus/core.rb
29 def convert_exception_class(exception, klass)
30   return exception if exception.is_a?(klass)
31 
32   e = klass.new("#{exception.class}: #{exception.message}")
33   e.wrapped_exception = exception
34   e.set_backtrace(exception.backtrace)
35   e
36 end
dump_job(job) click to toggle source

Serializes a Ruby object for publishing to RabbitMQ.

   # File lib/cuniculus/core.rb
17 def dump_job(job)
18   ::JSON.dump(job)
19 end
load_job(rmq_msg) click to toggle source

Convert a RabbitMQ message into Ruby object for processing.

   # File lib/cuniculus/core.rb
12 def load_job(rmq_msg)
13   ::JSON.parse(rmq_msg)
14 end
mark_time() click to toggle source
   # File lib/cuniculus/core.rb
38 def mark_time
39   Process.clock_gettime(Process::CLOCK_MONOTONIC)
40 end