tags:

views:

91

answers:

2

Hi, I'm working with dRuby and basicly I'm calling a remote method that returns me an object.

In the clientside I have this code:

handle_error(response) if response.is_a?(Error)

where response is the DRbObject. (I've developed this code before using dRuby and I'm returning an Error object if something went wrong). The problem is that now

response.is_a?(Error)

comes back with "false" because the object is actually a DRbObject. Any idea on how I can check the class of my application object?

Thanks! Roberto

+3  A: 

Although I'm not sure how DRb manages the remote objects, I'd expect it to modify #kind_of? to keep the class hierarchy on the remote object, so you could do:

response.kind_of?(Error)

If this doesn't work you can always ask it if it responds to an specific method and go from there

response.respond_to?(some_method_on_your_errors)
Federico Builes
+1  A: 

Could you not work around the problem by using Duck Typing? Instead of checking for whether the object is an Error, check whether the object responds to a call to get the error information. If it does, handle the error according to that information, otherwise handle the (non-error) response.

Richard Turner