in reply to ISA but no farther?

Why not ref($obj) eq "OP"? But usually needing to know if something is just an OP, not a subclass thereof, does indicate a poor class structure. Why do you need to know?

Replies are listed 'Best First'.
Re^2: ISA but no farther?
by diotalevi (Canon) on Jul 20, 2006 at 16:33 UTC

    If I give you a Test::MockObject that can do everything an OP object can but isn't actually blessed into the OP class, you'll think you don't have an OP object if you use ref($obj) eq 'OP. The point is that I want to rule out things that say they are subclasses of OP but not things that would like to think that they are really, truely, an OP object.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

      Sorry, missed that part; then you need to fix Test::MockObject to allow something like
      ref($obj) eq 'OP' || ref($obj) eq 'Test::MockObject' && $obj->mocks('O +P')

        That's nasty. I'd just be requiring that objects be always mocked through Test::MockObject instead of some other kind of proxy or whatever.

        ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊