Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Created June 15, 2010 10:59
Show Gist options
  • Save j1n3l0/438975 to your computer and use it in GitHub Desktop.
Save j1n3l0/438975 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use Modern::Perl;
use Test::Most;
=head1 OVERVIEW
Moose will load a class specified via an attributes C<isa> option.
=cut
{
package Foo;
use Moose;
has bar => (
isa => 'REST::Client',
is => 'ro',
default => sub { REST::Client->new() },
handles => ['GET'],
);
::dies_ok { Foo->new->GET($0) }
'does not automatically load REST::Client via isa';
}
{
package Bar;
use Moose;
extends 'Foo';
has '+bar' => (
default => sub {
require REST::Client;
REST::Client->new();
},
);
::lives_ok { Bar->new->GET($0) }
'now passes as REST::Client is explicitely required';
}
done_testing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment