It? and dRuby objects

I work with dRuby and basically I call a remote method that returns an object to me.

In clientide, I have this code:

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

where the answer is DRbObject. (I developed this code before using dRuby, and I return an Error object if something went wrong). The problem is that now

response.is_a?(Error)

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

Thank! Roberto

+3
source share
2 answers

Although I'm not sure how DRb manages remote objects, do I expect it to change #kind_of? to maintain the class hierarchy on the remote object so you can:

response.kind_of?(Error)

, ,

response.respond_to?(some_method_on_your_errors)
+3

, Duck Typing? , , , , . , , ( ).

+1

Source: https://habr.com/ru/post/1698136/


All Articles