| 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::Attribute; | ||||||||||
| 11 | 2 | our $AUTHORITY = 'cpan:RSRCHBOY'; | |||||||||
| 12 | 2 | $MooseX::CurriedDelegation::Trait::Attribute::VERSION = '0.003'; | |||||||||
| 13 | # ABSTRACT: The great new MooseX::CurriedDelegation! | ||||||||||
| 14 | |||||||||||
| 15 | 2 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 2 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 2 | ▶ | use MooseX::Util 'with_traits'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 2 | ▶ | use aliased 'MooseX::CurriedDelegation::Trait::Method::Delegation' => 'OurMethodTrait'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | 2 | ▶ | sub method_curried_delegation_metaclass { | ||||||||
|
Subroutine
method_curried_delegation_metaclass: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 24 | 2 | my $self = shift @_; | |||||||||
| 25 | |||||||||||
| 26 | 2 | return with_traits($self->delegation_metaclass => OurMethodTrait); | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 2 | ▶ | around _make_delegation_method => sub { | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||
| 30 | 2 | my ($orig, $self) = (shift, shift); | |||||||||
| 31 | 2 | my ($handle_name, $delegation_hash) = @_; | |||||||||
| 32 | |||||||||||
| 33 | ### $delegation_hash | ||||||||||
| 34 | 2 | ▶ | return $self->$orig(@_) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | unless 'HASH' eq ref $delegation_hash; | ||||||||||
| 36 | |||||||||||
| 37 | 2 | ▶ | confess "We should never have more than one key when setting up delegation: $handle_name" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | if keys %$delegation_hash > 1; | ||||||||||
| 39 | |||||||||||
| 40 | 2 | my ($method_to_call) = keys %$delegation_hash; | |||||||||
| 41 | 2 | my @curry_args = @{ $delegation_hash->{$method_to_call} }; | |||||||||
| 42 | 2 | my $curry_coderef = shift @curry_args; | |||||||||
| 43 | |||||||||||
| 44 | ### $method_to_call | ||||||||||
| 45 | ### @curry_args | ||||||||||
| 46 | |||||||||||
| 47 | 2 | return $self->method_curried_delegation_metaclass->new( | |||||||||
| 48 | name => $handle_name, | ||||||||||
| 49 | package_name => $self->associated_class->name, | ||||||||||
| 50 | attribute => $self, | ||||||||||
| 51 | delegate_to_method => $method_to_call, | ||||||||||
| 52 | curry_coderef => $curry_coderef, | ||||||||||
| 53 | curried_arguments => \@curry_args, | ||||||||||
| 54 | ); | ||||||||||
| 55 | 2 | }; | |||||||||
| 56 | |||||||||||
| 57 | 2 | !!42; | |||||||||
| 58 | |||||||||||
| 59 | __END__ | ||||||||||