Test-Mock-Object
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Test/Mock/Object/Chain.pm view on Meta::CPAN
if ( @$chain < 1 ) {
carp::confess(
"must have at least one method name to call on chain for $class");
}
my $last = pop @$chain;
while ( my $method = pop @$chain ) {
$last = _add_link( $method => $last );
}
return blessed $last ? $last : bless $last => $class;
}
sub _add_link {
my ( $method, $value ) = @_;
my $class = __PACKAGE__;
my $instance;
if ( 'ARRAY' eq ref $method ) {
( $instance, $method ) = @$method;
if ( $instance->isa($class) ) {
$instance->{$method} = $value;
return $instance;
}
else {
croak("Aref components in method chains must be [\$link, $value]");
}
}
else {
return bless { $method => $value } => $class;
}
}
sub AUTOLOAD {
my $self = shift;
our $AUTOLOAD;
$AUTOLOAD =~ s/.+:://;
if ( !exists $self->{$AUTOLOAD} ) {
my $class = ref $self;
croak(
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.374 second using v1.00-cache-2.02-grep-82fe00e-cpan-9e6bc14194b )