lib/nadir.rb in nadir-1.1.10 vs lib/nadir.rb in nadir-1.2.0

- old
+ new

@@ -20,18 +20,36 @@ end def notify(exception, params = {}) return false unless config.validate - notification = Notification.new exception, params + notification = Notification.new(exception, process_params(params)) transport.deliver notification.to_params true rescue => e logger.error "[Nadir] Internal error: #{e.inspect}" false + end + + def process_params(params) + ctx = Thread.current[:nadir_context] + + if ctx + params[:job] = ctx.delete(:job) if ctx[:job] + params[:context] = ctx if ctx + end + + params + end + + def with_context(payload) + Thread.current[:nadir_context] = payload + yield + ensure + Thread.current[:nadir_context] = nil end private def transport