| 1 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # This file is part of MooseX-CurriedDelegation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # This software is Copyright (c) 2012 by Chris Weyl. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # This is free software, licensed under: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # The GNU Lesser General Public License, Version 2.1, February 1999 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | package MooseX::CurriedDelegation::Trait::Method::Delegation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | our $AUTHORITY = 'cpan:RSRCHBOY'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | $MooseX::CurriedDelegation::Trait::Method::Delegation::VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # ABSTRACT: A trait for curried delegation methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # debugging... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | #use Smart::Comments; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | has curry_coderef => (is => 'ro', isa => 'Coderef', required => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # _initialize_body() is largely lifted right from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # Moose::Meta::Method::Delegation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | sub _initialize_body { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize_body: called CC=1 SCAR=1.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | my $method_to_call = $self->delegate_to_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # XXX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | #return $self->{body} = $method_to_call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # if ref $method_to_call; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | my $accessor = $self->_get_delegate_accessor; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | my $handle_name = $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | return $self->{body} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=24.9
Subroutine
foo_del_one: called CC=5 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $instance = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $proxy = $instance->$accessor(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $curry_coderef = $self->curry_coderef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ### $curry_coderef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | my $error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition16%1/6
ref $proxy and not builtin::blessed($proxy)
ref $proxy and not builtin::blessed($proxy)
MC/DC0%0/2
ref $proxy and not builtin::blessed($proxy)
ref $proxy
not builtin::blessed($proxy)
MC/DC0%0/2
ref $proxy and not builtin::blessed($proxy)
ref $proxy
not builtin::blessed($proxy)
Truth table0%0/3
A and not(B)
A= ref $proxyB= not builtin::blessed($proxy)
Truth table33%1/3
A and not(B)
A= ref $proxyB= not builtin::blessed($proxy)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | = !defined $proxy ? ' is not defined' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | : ref($proxy) && !blessed($proxy) ? qq{ is not an object (got '$proxy')} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->throw_error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | "Cannot delegate $handle_name to $method_to_call because " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | . "the value of " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | . $self->associated_attribute->name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | . $error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | method_name => $method_to_call, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | object => $instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | unshift @_, @{ $self->curried_arguments }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | unshift @_, $instance->$curry_coderef(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $proxy->$method_to_call(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | !!42; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||