POE.pm

filter: Statementstmt 100% 21 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 50.0% 1 / 2 totaltotal 96.4% 27 / 28 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
init_meta
1.0
CRAP 1.0
« POE/SweetArgs.pm ↑ Summary POE/Role.pm »
1 package MooseX::POE;
2 {
3 16 $MooseX::POE::VERSION = '0.215';
4 }
5 # ABSTRACT: The Illicit Love Child of Moose and POE
6  
7 24 ▶use Moose ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 ▶use Moose::Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 16 my ( $import, $unimport, $init_meta ) = Moose::Exporter->setup_import_methods(
11 with_caller => [qw(event)],
12 also => 'Moose',
13 install => [qw(import unimport)],
14 class_metaroles => {
15 class => ['MooseX::POE::Meta::Trait::Class'],
16 instance => ['MooseX::POE::Meta::Trait::Instance'],
17 },
18 base_class_roles => ['MooseX::POE::Meta::Trait::Object'],
19 );
20  
21 24 ▶sub init_meta {
Subroutine init_meta: called CC=1 SCAR=0.0
Pod undocumented
22 24 my ( $class, %args ) = @_;
23  
24 24 my $for = $args{for_class};
25 16 ▶ eval qq{package $for; use POE; };
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 24 Moose->init_meta( for_class => $for );
28  
29 24 goto $init_meta;
30 }
31  
32 19 ▶sub event {
Subroutine event: called CC=1 SCAR=0.0
Pod documented
33 19 my ( $caller, $name, $method ) = @_;
34 19 my $class = Moose::Meta::Class->initialize($caller);
35 19 $class->add_state_method( $name => $method );
36 }
37  
38 16 1;
39  
40  
41 =pod
42  
43 =head1 NAME
44  
45 MooseX::POE - The Illicit Love Child of Moose and POE
46  
47 =head1 VERSION
48  
49 version 0.215
50  
51 =head1 SYNOPSIS
52  
53 package Counter;
54 use MooseX::POE;
55  
56 has count => (
57 isa => 'Int',
58 is => 'rw',
59 lazy => 1,
60 default => sub { 0 },
61 );
62  
63 sub START {
64 my ($self) = @_;
65 $self->yield('increment');
66 }
67  
68 event increment => sub {
69 my ($self) = @_;
70 print "Count is now " . $self->count . "\n";
71 $self->count( $self->count + 1 );
72 $self->yield('increment') unless $self->count > 3;
73 };
74  
75 no MooseX::POE;
76  
77 Counter->new();
78 POE::Kernel->run();
79  
80 or with L<MooseX::Declare|MooseX::Declare>:
81  
82 class Counter {
83 use MooseX::POE::SweetArgs qw(event);
84
85 has count => (
86 isa => 'Int',
87 is => 'rw',
88 lazy => 1,
89 default => sub { 0 },
90 );
91
92 sub START {
93 my ($self) = @_;
94 $self->yield('increment')
95 }
96
97 event increment => sub {
98 my ($self) = @_;
99 print "Count is now " . $self->count . "\n";
100 $self->count( $self->count + 1 );
101 $self->yield('increment') unless $self->count > 3;
102 }
103 }
104  
105 Counter->new();
106 POE::Kernel->run();
107  
108 =head1 DESCRIPTION
109  
110 MooseX::POE is a L<Moose> wrapper around a L<POE::Session>.
111  
112 =head1 METHODS
113  
114 =head2 event $name $subref
115  
116 Create an event handler named $name.
117  
118 =head2 get_session_id
119  
120 Get the internal POE Session ID, this is useful to hand to other POE aware
121 functions.
122  
123 =head2 yield
124  
125 =head2 call
126  
127 =head2 delay
128  
129 =head2 alarm
130  
131 =head2 alarm_add
132  
133 =head2 delay_add
134  
135 =head2 alarm_set
136  
137 =head2 alarm_adjust
138  
139 =head2 alarm_remove
140  
141 =head2 alarm_remove_all
142  
143 =head2 delay_set
144  
145 =head2 delay_adjust
146  
147 A cheap alias for the same POE::Kernel function which will gurantee posting to the object's session.
148  
149 =head2 STARTALL
150  
151 =head2 STOPALL
152  
153 =head1 KEYWORDS
154  
155 =head1 METHODS
156  
157 Default POE-related methods are provided by L<MooseX::POE::Meta::Trait::Object|MooseX::POE::Meta::Trait::Object>
158 which is applied to your base class (which is usually L<Moose::Object|Moose::Object>) when
159 you use this module. See that module for the documentation for. Below is a list
160 of methods on that class so you know what to look for:
161  
162 =head1 NOTES ON USAGE WITH L<MooseX::Declare>
163  
164 L<MooseX::Declare|MooseX::Declare> support is still "experimental". Meaning that I don't use it,
165 I don't have any code that uses it, and thus I can't adequately say that it
166 won't cause monkeys to fly out of any orifices on your body beyond what the
167 tests and the SYNOPSIS cover.
168  
169 That said there are a few caveats that have turned up during testing.
170  
171 1. The C<method> keyword doesn't seem to work as expected. This is an
172 integration issue that is being resolved but I want to wait for
173 L<MooseX::Declare|MooseX::Declare> to gain some more polish on their slurpy
174 arguments.
175  
176 2. MooseX::POE attempts to re-export L<Moose>, which
177 L<MooseX::Declare> has already exported in a custom fashion.
178 This means that you'll get a keyword clash between the features that
179 L<MooseX::Declare|MooseX::Declare> handles for you and the features that Moose
180 handles. To work around this you'll need to write:
181  
182 use MooseX::POE qw(event);
183 # or
184 use MooseX::POE::SweetArgs qw(event);
185 # or
186 use MooseX::POE::Role qw(event);
187  
188 to keep MooseX::POE from exporting the sugar that
189 L<MooseX::Declare|MooseX::Declare> doesn't like. This is fixed in the Git
190 version of L<MooseX::Declare|MooseX::Declare> but that version (as of this
191 writing) is not on the CPAN.
192  
193 =head1 SEE ALSO
194  
195 =for :list * L<Moose|Moose>
196 * L<POE|POE>
197  
198 =head1 AUTHORS
199  
200 =over 4
201  
202 =item *
203  
204 Chris Prather <chris@prather.org>
205  
206 =item *
207  
208 Ash Berlin <ash@cpan.org>
209  
210 =item *
211  
212 Chris Williams <chris@bingosnet.co.uk>
213  
214 =item *
215  
216 Yuval (nothingmuch) Kogman
217  
218 =item *
219  
220 Torsten Raudssus <torsten@raudssus.de> L<http://www.raudssus.de/>
221  
222 =back
223  
224 =head1 COPYRIGHT AND LICENSE
225  
226 This software is copyright (c) 2010 by Chris Prather, Ash Berlin, Chris Williams, Yuval Kogman, Torsten Raudssus.
227  
228 This is free software; you can redistribute it and/or modify it under
229 the same terms as the Perl 5 programming language system itself.
230  
231 =cut
232  
233  
234 __END__
« POE/SweetArgs.pm ↑ Summary POE/Role.pm »