File Coverage

blib/lib/MooseX/CurriedDelegation/Trait/Attribute.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 20 20 100.0


line stmt bran cond sub pod time code
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             our $AUTHORITY = 'cpan:RSRCHBOY';
12             $MooseX::CurriedDelegation::Trait::Attribute::VERSION = '0.003';
13             # ABSTRACT: The great new MooseX::CurriedDelegation!
14              
15 1     1   4225 use Moose::Role;
  1         4340  
  1         5  
16 1     1   5316 use namespace::autoclean;
  1         6245  
  1         11  
17 1     1   418 use MooseX::Util 'with_traits';
  1         45643  
  1         9  
18              
19 1     1   635 use aliased 'MooseX::CurriedDelegation::Trait::Method::Delegation' => 'OurMethodTrait';
  1         554  
  1         9  
20              
21              
22              
23             sub method_curried_delegation_metaclass {
24 2     2 1 6 my $self = shift @_;
25              
26 2         11 return with_traits($self->delegation_metaclass => OurMethodTrait);
27             }
28              
29             around _make_delegation_method => sub {
30             my ($orig, $self) = (shift, shift);
31             my ($handle_name, $delegation_hash) = @_;
32              
33             ### $delegation_hash
34             return $self->$orig(@_)
35             unless 'HASH' eq ref $delegation_hash;
36              
37             confess "We should never have more than one key when setting up delegation: $handle_name"
38             if keys %$delegation_hash > 1;
39              
40             my ($method_to_call) = keys %$delegation_hash;
41             my @curry_args = @{ $delegation_hash->{$method_to_call} };
42             my $curry_coderef = shift @curry_args;
43              
44             ### $method_to_call
45             ### @curry_args
46              
47             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             };
56              
57             !!42;
58              
59             __END__
60              
61             =pod
62              
63             =encoding UTF-8
64              
65             =for :stopwords Chris Weyl
66              
67             =for :stopwords Wishlist flattr flattr'ed gittip gittip'ed
68              
69             =head1 NAME
70              
71             MooseX::CurriedDelegation::Trait::Attribute - The great new MooseX::CurriedDelegation!
72              
73             =head1 VERSION
74              
75             This document describes version 0.003 of MooseX::CurriedDelegation::Trait::Attribute - released November 09, 2016 as part of MooseX-CurriedDelegation.
76              
77             =head1 DESCRIPTION
78              
79             This is just a trait applied to the delegation method metaclass (generally
80             L<Moose::Meta::Method::Delegation>). No user-serviceable parts here.
81              
82             =head1 METHODS
83              
84             =head2 method_curried_delegation_metaclass
85              
86             Returns a class composed of the applied class' delegation metaclass and our
87             delegation method trait.
88              
89             =head1 SEE ALSO
90              
91             Please see those modules/websites for more information related to this module.
92              
93             =over 4
94              
95             =item *
96              
97             L<MooseX::CurriedDelegation|MooseX::CurriedDelegation>
98              
99             =item *
100              
101             L<MooseX::CurriedDelegation>
102              
103             =back
104              
105             =head1 BUGS
106              
107             Please report any bugs or feature requests on the bugtracker website
108             L<https://github.com/RsrchBoy/moosex-currieddelegation/issues>
109              
110             When submitting a bug or request, please include a test-file or a
111             patch to an existing test-file that illustrates the bug or desired
112             feature.
113              
114             =head1 AUTHOR
115              
116             Chris Weyl <cweyl@alumni.drew.edu>
117              
118             =head2 I'm a material boy in a material world
119              
120             =begin html
121              
122             <a href="https://gratipay.com/RsrchBoy/"><img src="http://img.shields.io/gratipay/RsrchBoy.svg" /></a>
123             <a href="http://bit.ly/rsrchboys-wishlist"><img src="http://wps.io/wp-content/uploads/2014/05/amazon_wishlist.resized.png" /></a>
124             <a href="https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fmoosex-currieddelegation&title=RsrchBoy's%20CPAN%20MooseX-CurriedDelegation&tags=%22RsrchBoy's%20MooseX-CurriedDelegation%20in%20the%20CPAN%22"><img src="http://api.flattr.com/button/flattr-badge-large.png" /></a>
125              
126             =end html
127              
128             Please note B<I do not expect to be gittip'ed or flattr'ed for this work>,
129             rather B<it is simply a very pleasant surprise>. I largely create and release
130             works like this because I need them or I find it enjoyable; however, don't let
131             that stop you if you feel like it ;)
132              
133             L<Flattr|https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fmoosex-currieddelegation&title=RsrchBoy's%20CPAN%20MooseX-CurriedDelegation&tags=%22RsrchBoy's%20MooseX-CurriedDelegation%20in%20the%20CPAN%22>,
134             L<Gratipay|https://gratipay.com/RsrchBoy/>, or indulge my
135             L<Amazon Wishlist|http://bit.ly/rsrchboys-wishlist>... If and *only* if you so desire.
136              
137             =head1 COPYRIGHT AND LICENSE
138              
139             This software is Copyright (c) 2012 by Chris Weyl.
140              
141             This is free software, licensed under:
142              
143             The GNU Lesser General Public License, Version 2.1, February 1999
144              
145             =cut