don't assume Scalar::Util is imported into the current package
[gitmo/Moo.git] / t / lib / MooObjectWithDelegate.pm
CommitLineData
777fcfcf 1package MooObjectWithDelegate;
2use ClassicObject;
ee22f92c 3use Scalar::Util ();
777fcfcf 4use Moo;
5
6has 'delegated' => (
7 is => 'ro',
8 isa => sub {
ee22f92c 9 do { $_[0] && Scalar::Util::blessed($_[0]) }
777fcfcf 10 or die "Not an Object!";
11 },
12 lazy => 1,
13 builder => '_build_delegated',
14 handles => [qw/connect/],
15);
16
17sub _build_delegated {
18 my $self = shift;
19 return ClassicObject->new;
20}
21
22around 'connect', sub {
23 my ($orig, $self, @args) = @_;
24 return $self->$orig(@args) . 'b';
25};
26
27
281;