File Coverage

blib/lib/MooseX/CurriedDelegation/Trait/Attribute.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 22 22 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             BEGIN {
12 1     1   17814 $MooseX::CurriedDelegation::Trait::Attribute::AUTHORITY = 'cpan:RSRCHBOY';
13             }
14             $MooseX::CurriedDelegation::Trait::Attribute::VERSION = '0.002';
15             # ABSTRACT: The great new MooseX::CurriedDelegation!
16              
17 1     1   10 use Moose::Role;
  1         2  
  1         11  
18 1     1   16822 use namespace::autoclean;
  1         3955  
  1         8  
19 1     1   11922 use MooseX::Util 'with_traits';
  1         534517  
  1         19  
20              
21 1     1   1462 use aliased 'MooseX::CurriedDelegation::Trait::Method::Delegation' => 'OurMethodTrait';
  1         877  
  1         9  
22              
23              
24              
25             sub method_curried_delegation_metaclass {
26 2     2 1 6 my $self = shift @_;
27              
28 2         13 return with_traits($self->delegation_metaclass => OurMethodTrait);
29             }
30              
31             around _make_delegation_method => sub {
32             my ($orig, $self) = (shift, shift);
33             my ($handle_name, $delegation_hash) = @_;
34              
35             ### $delegation_hash
36             return $self->$orig(@_)
37             unless 'HASH' eq ref $delegation_hash;
38              
39             confess "We should never have more than one key when setting up delegation: $handle_name"
40             if keys %$delegation_hash > 1;
41              
42             my ($method_to_call) = keys %$delegation_hash;
43             my @curry_args = @{ $delegation_hash->{$method_to_call} };
44             my $curry_coderef = shift @curry_args;
45              
46             ### $method_to_call
47             ### @curry_args
48              
49             return $self->method_curried_delegation_metaclass->new(
50             name => $handle_name,
51             package_name => $self->associated_class->name,
52             attribute => $self,
53             delegate_to_method => $method_to_call,
54             curry_coderef => $curry_coderef,
55             curried_arguments => \@curry_args,
56             );
57             };
58              
59             !!42;
60              
61             __END__
62              
63             =pod
64              
65             =encoding UTF-8
66              
67             =for :stopwords Chris Weyl
68              
69             =for :stopwords Wishlist flattr flattr'ed gittip gittip'ed
70              
71             =head1 NAME
72              
73             MooseX::CurriedDelegation::Trait::Attribute - The great new MooseX::CurriedDelegation!
74              
75             =head1 VERSION
76              
77             This document describes version 0.002 of MooseX::CurriedDelegation::Trait::Attribute - released May 19, 2014 as part of MooseX-CurriedDelegation.
78              
79             =head1 DESCRIPTION
80              
81             This is just a trait applied to the delegation method metaclass (generally
82             L<Moose::Meta::Method::Delegation>). No user-serviceable parts here.
83              
84             =head1 METHODS
85              
86             =head2 method_curried_delegation_metaclass
87              
88             Returns a class composed of the applied class' delegation metaclass and our
89             delegation method trait.
90              
91             =head1 SEE ALSO
92              
93             Please see those modules/websites for more information related to this module.
94              
95             =over 4
96              
97             =item *
98              
99             L<MooseX::CurriedDelegation|MooseX::CurriedDelegation>
100              
101             =item *
102              
103             L<MooseX::CurriedDelegation>
104              
105             =back
106              
107             =head1 SOURCE
108              
109             The development version is on github at L<http://https://github.com/RsrchBoy/moosex-currieddelegation>
110             and may be cloned from L<git://https://github.com/RsrchBoy/moosex-currieddelegation.git>
111              
112             =head1 BUGS
113              
114             Please report any bugs or feature requests on the bugtracker website
115             https://github.com/RsrchBoy/moosex-currieddelegation/issues
116              
117             When submitting a bug or request, please include a test-file or a
118             patch to an existing test-file that illustrates the bug or desired
119             feature.
120              
121             =head1 AUTHOR
122              
123             Chris Weyl <cweyl@alumni.drew.edu>
124              
125             =head2 I'm a material boy in a material world
126              
127             =begin html
128              
129             <a href="https://www.gittip.com/RsrchBoy/"><img src="https://raw.githubusercontent.com/gittip/www.gittip.com/master/www/assets/%25version/logo.png" /></a>
130             <a href="http://bit.ly/rsrchboys-wishlist"><img src="http://wps.io/wp-content/uploads/2014/05/amazon_wishlist.resized.png" /></a>
131             <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>
132              
133             =end html
134              
135             Please note B<I do not expect to be gittip'ed or flattr'ed for this work>,
136             rather B<it is simply a very pleasant surprise>. I largely create and release
137             works like this because I need them or I find it enjoyable; however, don't let
138             that stop you if you feel like it ;)
139              
140             L<Flattr this|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>,
141             L<gittip me|https://www.gittip.com/RsrchBoy/>, or indulge my
142             L<Amazon Wishlist|http://bit.ly/rsrchboys-wishlist>... If you so desire.
143              
144             =head1 COPYRIGHT AND LICENSE
145              
146             This software is Copyright (c) 2012 by Chris Weyl.
147              
148             This is free software, licensed under:
149              
150             The GNU Lesser General Public License, Version 2.1, February 1999
151              
152             =cut