File Coverage

blib/lib/MooseX/POE/SweetArgs.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package MooseX::POE::SweetArgs;
2             {
3             $MooseX::POE::SweetArgs::VERSION = '0.215';
4             }
5             # ABSTRACT: sugar around MooseX::POE event arguments
6              
7 1     1   26168 use Moose ();
  0            
  0            
8             use MooseX::POE;
9             use Moose::Exporter;
10              
11              
12             Moose::Exporter->setup_import_methods(
13             also => 'MooseX::POE',
14             );
15              
16             sub init_meta {
17             my ($class, %args) = @_;
18             MooseX::POE->import({ into => $args{for_class} });
19              
20             Moose::Util::MetaRole::apply_metaroles(
21             for => $args{for_class},
22             class_metaroles => {
23             class => ['MooseX::POE::Meta::Trait::SweetArgs'],
24             },
25             );
26             }
27              
28              
29             1;
30              
31              
32             =pod
33              
34             =head1 NAME
35              
36             MooseX::POE::SweetArgs - sugar around MooseX::POE event arguments
37              
38             =head1 VERSION
39              
40             version 0.215
41              
42             =head1 SYNOPSIS
43              
44             package Thing;
45             use MooseX::POE::SweetArgs;
46              
47             # declare events like usual
48             event on_success => sub {
49             # unpack args like a Perl sub, not a POE event
50             my ($self, $foo, $bar) = @_;
51             ...
52             POE::Kernel->yield('foo');
53             ...
54             };
55              
56             =head1 DESCRIPTION
57              
58             Normally, when using MooseX::POE, subs declared as events need to use POE
59             macros for unpacking C<@_>, e.g.:
60              
61             my ($self, $foo, $bar) = @_[OBJECT, ARG0..$#_];
62              
63             Using MooseX::POE::SweetArgs as a metaclass lets you avoid this, and just use
64             C<@_> as normal:
65              
66             my ($self, $foo, $bar) = @_;
67              
68             Since the POE kernel is a singleton, you can access it using class methods, as
69             shown in the synopsis.
70              
71             In all other respects, this behaves exactly like MooseX::POE
72              
73             =for :list * L<MooseX::POE|MooseX::POE>
74              
75             =head1 AUTHORS
76              
77             =over 4
78              
79             =item *
80              
81             Chris Prather <chris@prather.org>
82              
83             =item *
84              
85             Ash Berlin <ash@cpan.org>
86              
87             =item *
88              
89             Chris Williams <chris@bingosnet.co.uk>
90              
91             =item *
92              
93             Yuval (nothingmuch) Kogman
94              
95             =item *
96              
97             Torsten Raudssus <torsten@raudssus.de> L<http://www.raudssus.de/>
98              
99             =back
100              
101             =head1 COPYRIGHT AND LICENSE
102              
103             This software is copyright (c) 2010 by Chris Prather, Ash Berlin, Chris Williams, Yuval Kogman, Torsten Raudssus.
104              
105             This is free software; you can redistribute it and/or modify it under
106             the same terms as the Perl 5 programming language system itself.
107              
108             =cut
109              
110              
111             __END__
112