You can access all Bindings ex.bindings . To make sure that you are properly attached to your work, you should check the receiver as follows: 1 :
method_binding = ex.bindings.find { |b| b.receiver.is_a?(self.class) }
Then you can get all local variables with .local_variable_get . Since the method arguments are also local variables, you can at least get them explicitly:
user = method_binding.local_variable_get(:user) post = method_binding.local_variable_get(:post)
So for an example:
def perform object end rescue_from Exception do |e| if e.class != ActiveRecord::RecordNotFound method_binding = ex.bindings.find { |b| b.receiver.is_a?(self.class) } object = method_binding.local_variable_get(:object)
<sub> 1. It is still possible that this binding does not apply to perform if you call other instance methods in the task execution method and an error occurs there. This can also be taken into account, but not indicated for brevity.
Markus
source share