Reflex::Role - define a Reflex paramaterized role
This document describes version 0.092, released on November 29, 2011.
TODO - Changed again;
package Reflex::Role::Streaming; use Reflex::Role; use Scalar::Util qw(weaken); attribute_parameter handle => "handle"; callback_parameter cb_data => qw( on handle data ); callback_parameter cb_error => qw( on handle error ); callback_parameter cb_closed => qw( on handle closed ); method_parameter method_put => qw( put handle _ ); method_parameter method_stop => qw( stop handle _ ); role { my $p = shift; my $h = $p->handle(); my $cb_error = $p->cb_error(); with 'Reflex::Role::Collectible'; method-emit_and_stop $cb_error => $p->ev_error(); with 'Reflex::Role::Reading' => { handle => $h, cb_data => $p->cb_data(), cb_error => $cb_error, cb_closed => $p->cb_closed(), }; with 'Reflex::Role::Readable' => { handle => $h, active => 1, }; with 'Reflex::Role::Writing' => { handle => $h, cb_error => $cb_error, method_put => $p->method_put(), }; with 'Reflex::Role::Writable' => { handle => $h, }; # Multiplex a single stop() to the sub-roles. method $p->method_stop() => sub { my $self = shift; $self->stop_handle_readable(); $self->stop_handle_writable(); }; }; 1;
Reflex::Role defines a class as a Reflex parameterized role. It adds a few Reflex-specific exports to MooseX::Role::Parameterized.
It will be very helpful to understand the MooseX::Role::Parameterized declarations parameter, role and method before continuing. A basic familiarity with Moose::Role is also assumed.
parameter
role
method
Reflex::Role adds a few declarations to MooseX::Role::Parameterized. The role parameter declarations define new parameters for Reflex roles. They're shorthands for MooseX::Role::Parameterized parameter declarations.
Synopsis:
attribute_parameter attribute_name => "default_name";
attribute_parameter declares a role parameter that will accept an attribute name from the consumer. It also specifies a default attribute name.
attribute_parameter
attribute_parameter is a convenience declaration. The synopsis declaration is equivalent to this MooseX::Role::Parameterized syntax
parameter attribute_name => ( isa => 'Str', default => $default, );
callback_parameter callback_name => qw( prefix attribute_param suffix);
callback_parameter declares a role parameter that will accept a callback method name. It alsp specifies a default method name, which is the catenation of a prefix, the value of an attribute parameter, and a suffix. A prefix or suffix of "_" will cause that segment of the default to be ignored.
callback_parameter
callback_parameter is a convenience declaration. The synopsis is equivalent to this MooseX::Role::Parameterized syntax:
parameter callback_name => ( isa => 'Str', lazy => 1, default => sub { join( "_", grep { defined() and $_ ne "_" } $prefix, shift()->$attribute_param(), $suffix ) }, );
method_parameter method_name => qw( prefix attribute_param suffix );
method_parameter declares a role parameter that will accept a method name from the consumer. It also specifies a default method name, which is the catenation of a prefix, the value of an attribute parameter, and a suffix. A prefix or suffix of "_" will cause that segment of the default to be ignored.
method_parameter
method_parameter is a convenience declaration. The synopsis is equivalent to this MooseX::Role::Parameterized syntax:
parameter method_name => ( isa => 'Str', lazy => 1, default => sub { join( "_", grep { defined() and $_ ne "_" } $prefix, shift()->$attribute_param(), $suffix ) }, );
I'm looking for better names for Reflex::Role's exported declarations. Please suggest some.
Nearly everything in the Reflex::Role namespace.
Please see those modules/websites for more information related to this module.
Reflex
Moose
MooseX::Role::Parameterized
All the Reflex roles.
"ACKNOWLEDGEMENTS" in Reflex
"ASSISTANCE" in Reflex
"AUTHORS" in Reflex
"BUGS" in Reflex
"CONTRIBUTORS" in Reflex
"COPYRIGHT" in Reflex
"LICENSE" in Reflex
"TODO" in Reflex
No bugs have been reported.
Please report any bugs or feature requests through the web interface at http://rt.cpan.org.
Rocco Caputo <rcaputo@cpan.org>
This software is copyright (c) 2011 by Rocco Caputo.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see http://search.cpan.org/dist/Reflex/.
The development version lives at http://github.com/rcaputo/reflex and may be cloned from git://github.com/rcaputo/reflex.git. Instead of sending patches, please fork this project using the standard git and github infrastructure.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
To install Reflex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Reflex
CPAN shell
perl -MCPAN -e shell install Reflex
For more information on module installation, please visit the detailed CPAN module installation guide.