in reply to Mocking Class::DBI stringification

Below's an example of subclassing T:MO to achieve this...

My question, I guess: is there a better way to achieve this w/o all the multiple subclassing? (Would have to do this for each Mock Class, for if just overloaded '""' in Test:MockObject itself, all the mocked classes would stringify the same way, which isn't what I need.

use strict; use warnings FATAL => 'all'; use Test::MockObject; use Test::More tests => 2; my $id = -1; package MockFoo; use base qw(Test::MockObject); use overload '""' => sub {return $id}; package main; my $c = MockFoo->new; $c->set_isa('Foo'); $c->set_bound('id', \$id); is($c->id, -1, 'accessor'); is('' . $c, -1, 'stringify');