File Coverage

blib/lib/MooseX/Util.pm
Criterion Covered Total %
statement 16 16 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 24 25 96.0


line stmt bran cond sub pod time code
1             #
2             # This file is part of MooseX-Util
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::Util;
11             BEGIN {
12 2     2   758048 $MooseX::Util::AUTHORITY = 'cpan:RSRCHBOY';
13             }
14             # git description: 0.002-3-g0d45e2b
15             $MooseX::Util::VERSION = '0.003';
16              
17             # ABSTRACT: Moose::Util extensions
18              
19 2     2   13 use strict;
  2         3  
  2         67  
20 2     2   10 use warnings;
  2         3  
  2         61  
21              
22 2     2   9 use parent 'Moose::Util';
  2         4  
  2         15  
23              
24 2     2   1380 use MooseX::Util::Meta::Class;
  2         11  
  2         338  
25              
26              
27             # TODO allow with_traits() to be curried with different class metaclasses?
28              
29             sub with_traits {
30 3     3 1 9783 my ($class, @roles) = @_;
31 3 50       14 return $class unless @roles;
32 3         41 return MooseX::Util::Meta::Class->create_anon_class(
33             superclasses => [$class],
34             roles => \@roles,
35             cache => 1,
36             )->name;
37             }
38              
39              
40             !!42;
41              
42             __END__
43              
44             =pod
45              
46             =encoding UTF-8
47              
48             =for :stopwords Chris Weyl
49              
50             =for :stopwords Wishlist flattr flattr'ed gittip gittip'ed
51              
52             =head1 NAME
53              
54             MooseX::Util - Moose::Util extensions
55              
56             =head1 VERSION
57              
58             This document describes version 0.003 of MooseX::Util - released May 22, 2014 as part of MooseX-Util.
59              
60             =head1 SYNOPSIS
61              
62             use MooseX::Util qw{ ensure_all_roles with_traits };
63              
64             # profit!
65              
66             =head1 DESCRIPTION
67              
68             This is a utility module that handles all of the same functions that
69             L<Moose::Util> handles. In fact, most of the functions exported by this
70             package are simply re-exports from L<Moose::Util>, so you're recommended to
71             read the documentation of that module for a comprehensive view.
72              
73             However.
74              
75             We've re-implemented a number of the functions our parent provides, for a
76             variety of reasons. Those functions are documented here.
77              
78             =head1 FUNCTIONS
79              
80             =head2 with_traits(<classname> => (<trait1>, ... )
81              
82             Given a class and one or more traits, we construct an anonymous class that is
83             a subclass of the given class and consumes the traits given. This is exactly
84             the same as L<Moose::Util/with_traits>, except that we use
85             L<MooseX::Util::Meta::Class/create_anon_class> to construct the anonymous
86             class, rather than L<Moose::Meta::Class/create_anon_class> directly.
87              
88             Essentially, this means that when we do:
89              
90             my $anon_class_name = with_traits('Zombie::Catcher', 'SomeTrait');
91              
92             For $anon_class_name we get:
93              
94             Zombie::Catcher::__ANON__::SERIAL::1
95              
96             Rather than:
97              
98             Moose::Meta::Class::__ANON__::SERIAL::1
99              
100             This is nice because we have an idea of where the first anonymous class came
101             from, whereas the second one could could be from anywhere.
102              
103             =head1 SEE ALSO
104              
105             Please see those modules/websites for more information related to this module.
106              
107             =over 4
108              
109             =item *
110              
111             L<Moose::Util>
112              
113             =back
114              
115             =head1 SOURCE
116              
117             The development version is on github at L<http://https://github.com/RsrchBoy/moosex-util>
118             and may be cloned from L<git://https://github.com/RsrchBoy/moosex-util.git>
119              
120             =head1 BUGS
121              
122             Please report any bugs or feature requests on the bugtracker website
123             https://github.com/RsrchBoy/moosex-util/issues
124              
125             When submitting a bug or request, please include a test-file or a
126             patch to an existing test-file that illustrates the bug or desired
127             feature.
128              
129             =head1 AUTHOR
130              
131             Chris Weyl <cweyl@alumni.drew.edu>
132              
133             =head2 I'm a material boy in a material world
134              
135             =begin html
136              
137             <a href="https://www.gittip.com/RsrchBoy/"><img src="https://raw.githubusercontent.com/gittip/www.gittip.com/master/www/assets/%25version/logo.png" /></a>
138             <a href="http://bit.ly/rsrchboys-wishlist"><img src="http://wps.io/wp-content/uploads/2014/05/amazon_wishlist.resized.png" /></a>
139             <a href="https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fmoosex-util&title=RsrchBoy's%20CPAN%20MooseX-Util&tags=%22RsrchBoy's%20MooseX-Util%20in%20the%20CPAN%22"><img src="http://api.flattr.com/button/flattr-badge-large.png" /></a>
140              
141             =end html
142              
143             Please note B<I do not expect to be gittip'ed or flattr'ed for this work>,
144             rather B<it is simply a very pleasant surprise>. I largely create and release
145             works like this because I need them or I find it enjoyable; however, don't let
146             that stop you if you feel like it ;)
147              
148             L<Flattr this|https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fmoosex-util&title=RsrchBoy's%20CPAN%20MooseX-Util&tags=%22RsrchBoy's%20MooseX-Util%20in%20the%20CPAN%22>,
149             L<gittip me|https://www.gittip.com/RsrchBoy/>, or indulge my
150             L<Amazon Wishlist|http://bit.ly/rsrchboys-wishlist>... If you so desire.
151              
152             =head1 COPYRIGHT AND LICENSE
153              
154             This software is Copyright (c) 2012 by Chris Weyl.
155              
156             This is free software, licensed under:
157              
158             The GNU Lesser General Public License, Version 2.1, February 1999
159              
160             =cut