r45395 - in /trunk/libpoex-role-sessioninstantiation-perl: ./ debian/ lib/POEx/Role/ lib/POEx/Role/SessionInstantiation/ t/ t/lib/
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Mon Oct 5 19:39:57 UTC 2009
Author: gregoa
Date: Mon Oct 5 19:39:51 2009
New Revision: 45395
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=45395
Log:
yet another new upstream release
Added:
trunk/libpoex-role-sessioninstantiation-perl/lib/POEx/Role/SessionInstantiation/
- copied from r45394, branches/upstream/libpoex-role-sessioninstantiation-perl/current/lib/POEx/Role/SessionInstantiation/
trunk/libpoex-role-sessioninstantiation-perl/t/02-traits.t
- copied unchanged from r45394, branches/upstream/libpoex-role-sessioninstantiation-perl/current/t/02-traits.t
trunk/libpoex-role-sessioninstantiation-perl/t/lib/
- copied from r45394, branches/upstream/libpoex-role-sessioninstantiation-perl/current/t/lib/
Removed:
trunk/libpoex-role-sessioninstantiation-perl/Build.PL
Modified:
trunk/libpoex-role-sessioninstantiation-perl/Changes
trunk/libpoex-role-sessioninstantiation-perl/MANIFEST
trunk/libpoex-role-sessioninstantiation-perl/META.yml
trunk/libpoex-role-sessioninstantiation-perl/Makefile.PL
trunk/libpoex-role-sessioninstantiation-perl/README
trunk/libpoex-role-sessioninstantiation-perl/debian/changelog
trunk/libpoex-role-sessioninstantiation-perl/dist.ini
trunk/libpoex-role-sessioninstantiation-perl/lib/POEx/Role/Event.pm
trunk/libpoex-role-sessioninstantiation-perl/lib/POEx/Role/SessionInstantiation.pm
trunk/libpoex-role-sessioninstantiation-perl/t/00-load.t
trunk/libpoex-role-sessioninstantiation-perl/t/01-basic.t
Modified: trunk/libpoex-role-sessioninstantiation-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpoex-role-sessioninstantiation-perl/Changes?rev=45395&op=diff
==============================================================================
--- trunk/libpoex-role-sessioninstantiation-perl/Changes (original)
+++ trunk/libpoex-role-sessioninstantiation-perl/Changes Mon Oct 5 19:39:51 2009
@@ -1,4 +1,10 @@
-Revision history for POEx-Role-SessionInstantiation: 0.092460
+Revision history for POEx-Role-SessionInstantiation: 0.092673
+
+0.092673 2009-09-24 23:08:47 UTC
+ Update deps
+ Major refactor of guts to break out functionality into different roles
+ Implement traits (even parameterized ones) via import
+ Misc doc fixes
0.092460 2009-09-03 21:06:04 UTC
Depend on newer POEx::Types and let it set the POE version
Modified: trunk/libpoex-role-sessioninstantiation-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpoex-role-sessioninstantiation-perl/MANIFEST?rev=45395&op=diff
==============================================================================
--- trunk/libpoex-role-sessioninstantiation-perl/MANIFEST (original)
+++ trunk/libpoex-role-sessioninstantiation-perl/MANIFEST Mon Oct 5 19:39:51 2009
@@ -7,7 +7,14 @@
dist.ini
lib/POEx/Role/Event.pm
lib/POEx/Role/SessionInstantiation.pm
+lib/POEx/Role/SessionInstantiation/Meta/POEState.pm
+lib/POEx/Role/SessionInstantiation/Meta/Session/Events.pm
+lib/POEx/Role/SessionInstantiation/Meta/Session/Implementation.pm
+lib/POEx/Role/SessionInstantiation/Meta/Session/Magic.pm
+lib/POEx/Role/SessionInstantiation/Meta/Session/Sugar.pm
t/00-load.t
t/01-basic.t
+t/02-traits.t
+t/lib/MyTrait.pm
t/release-pod-coverage.t
t/release-pod-syntax.t
Modified: trunk/libpoex-role-sessioninstantiation-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpoex-role-sessioninstantiation-perl/META.yml?rev=45395&op=diff
==============================================================================
--- trunk/libpoex-role-sessioninstantiation-perl/META.yml (original)
+++ trunk/libpoex-role-sessioninstantiation-perl/META.yml Mon Oct 5 19:39:51 2009
@@ -2,16 +2,17 @@
abstract: 'Moose Role for turning ordinary objects into POE sessions'
author:
- 'Nicholas Perez <nperez at cpan.org>'
-generated_by: 'Dist::Zilla::Plugin::MetaYAML version 1.092400'
+generated_by: 'Dist::Zilla::Plugin::MetaYAML version 1.092670'
license: gpl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: POEx-Role-SessionInstantiation
requires:
- MooseX::Declare: 0.29
- POEx::Types: 0.092460
+ MooseX::Declare: 0.31
+ POE: 1.269
+ POEx::Types: 0.092670
Test::More: 0.92
resources:
repository: git://github.com/nperez/psm.git
-version: 0.092460
+version: 0.092673
Modified: trunk/libpoex-role-sessioninstantiation-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpoex-role-sessioninstantiation-perl/Makefile.PL?rev=45395&op=diff
==============================================================================
--- trunk/libpoex-role-sessioninstantiation-perl/Makefile.PL (original)
+++ trunk/libpoex-role-sessioninstantiation-perl/Makefile.PL Mon Oct 5 19:39:51 2009
@@ -9,12 +9,15 @@
NAME => 'POEx::Role::SessionInstantiation',
AUTHOR => 'Nicholas\ Perez\ \<nperez\@cpan\.org\>',
ABSTRACT => 'Moose\ Role\ for\ turning\ ordinary\ objects\ into\ POE\ sessions',
- VERSION => '0.092460',
+ VERSION => '0.092673',
EXE_FILES => [ qw() ],
(eval { ExtUtils::MakeMaker->VERSION(6.31) } ? (LICENSE => 'gpl') : ()),
PREREQ_PM => {
"Test::More" => '0.92',
- "MooseX::Declare" => '0.29',
- "POEx::Types" => '0.092460',
+ "MooseX::Declare" => '0.31',
+ "POE" => '1.269',
+ "POEx::Types" => '0.092670',
},
+ test => {TESTS => 't/*.t'}
);
+
Modified: trunk/libpoex-role-sessioninstantiation-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpoex-role-sessioninstantiation-perl/README?rev=45395&op=diff
==============================================================================
--- trunk/libpoex-role-sessioninstantiation-perl/README (original)
+++ trunk/libpoex-role-sessioninstantiation-perl/README Mon Oct 5 19:39:51 2009
@@ -1,7 +1,7 @@
This archive contains the distribution POEx-Role-SessionInstantiation, version
-0.092460:
+0.092673:
Moose Role for turning ordinary objects into POE sessions
Modified: trunk/libpoex-role-sessioninstantiation-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpoex-role-sessioninstantiation-perl/debian/changelog?rev=45395&op=diff
==============================================================================
--- trunk/libpoex-role-sessioninstantiation-perl/debian/changelog (original)
+++ trunk/libpoex-role-sessioninstantiation-perl/debian/changelog Mon Oct 5 19:39:51 2009
@@ -1,4 +1,4 @@
-libpoex-role-sessioninstantiation-perl (0.092460-1) UNRELEASED; urgency=low
+libpoex-role-sessioninstantiation-perl (0.092673-1) UNRELEASED; urgency=low
[ Nathan Handler ]
* debian/watch: Update to ignore development releases.
@@ -25,7 +25,7 @@
* New upstream release
* Update ryan52's email address
- -- Ryan Niebur <ryan at debian.org> Fri, 25 Sep 2009 00:26:06 -0700
+ -- gregor herrmann <gregoa at debian.org> Mon, 05 Oct 2009 21:38:39 +0200
libpoex-role-sessioninstantiation-perl (0.01-1) unstable; urgency=low
Modified: trunk/libpoex-role-sessioninstantiation-perl/dist.ini
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpoex-role-sessioninstantiation-perl/dist.ini?rev=45395&op=diff
==============================================================================
--- trunk/libpoex-role-sessioninstantiation-perl/dist.ini (original)
+++ trunk/libpoex-role-sessioninstantiation-perl/dist.ini Mon Oct 5 19:39:51 2009
@@ -8,16 +8,18 @@
[AutoVersion]
major = 0
+format = {{ $major }}.{{ cldr('yyDDD') }}3
[PodPurler]
[Prereq]
-POEx::Types = 0.092460
-MooseX::Declare = 0.29
+POE = 1.269
+POEx::Types = 0.092670
+MooseX::Declare = 0.31
Test::More = 0.92
[MetaResources]
repository = git://github.com/nperez/psm.git
[NextRelease]
-[ModuleBuild]
+
Modified: trunk/libpoex-role-sessioninstantiation-perl/lib/POEx/Role/Event.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpoex-role-sessioninstantiation-perl/lib/POEx/Role/Event.pm?rev=45395&op=diff
==============================================================================
--- trunk/libpoex-role-sessioninstantiation-perl/lib/POEx/Role/Event.pm (original)
+++ trunk/libpoex-role-sessioninstantiation-perl/lib/POEx/Role/Event.pm Mon Oct 5 19:39:51 2009
@@ -1,5 +1,6 @@
package POEx::Role::Event;
-our $VERSION = '0.092460';
+our $VERSION = '0.092673';
+
#ABSTRACT: Provide a decorator to label events
@@ -21,7 +22,7 @@
=head1 VERSION
-version 0.092460
+version 0.092673
=head1 AUTHOR
Modified: trunk/libpoex-role-sessioninstantiation-perl/lib/POEx/Role/SessionInstantiation.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpoex-role-sessioninstantiation-perl/lib/POEx/Role/SessionInstantiation.pm?rev=45395&op=diff
==============================================================================
--- trunk/libpoex-role-sessioninstantiation-perl/lib/POEx/Role/SessionInstantiation.pm (original)
+++ trunk/libpoex-role-sessioninstantiation-perl/lib/POEx/Role/SessionInstantiation.pm Mon Oct 5 19:39:51 2009
@@ -1,507 +1,46 @@
-package POEx::Role::SessionInstantiation;
-our $VERSION = '0.092460';
+{package POEx::Role::SessionInstantiation;
+our $VERSION = '0.092673';
+}
use MooseX::Declare;
#ABSTRACT: A Moose Role for turning objects into POE Sessions
-
-#lexical hack to get a static variable
-my $anonymous_poe;
role POEx::Role::SessionInstantiation
{
- use MooseX::Types::Moose('Str', 'Int', 'Any', 'HashRef', 'Object', 'ArrayRef', 'Maybe');
- use POEx::Types(':all');
- use Moose::Util::TypeConstraints;
- use POE;
+ use MooseX::Types::Moose(':all');
+ use MooseX::Types::Structured(':all');
use aliased 'POEx::Role::Event', 'Event';
- use overload '""' => sub
- {
- my $s = shift;
- return $s->orig if $s->orig;
- return $s;
- };
-
- use overload '!=' => sub
- {
- return "$_[0]" ne "$_[1]";
- };
-
- use overload '==' => sub
- {
- return "$_[0]" eq "$_[1]";
- };
-
- has orig => ( is => 'rw', isa => Str );
-
- has orig_name => ( is => 'rw', isa => Str );
-
-
- has heap =>
- (
- is => 'rw',
- isa => Any,
- default => sub { {} },
- lazy => 1,
- );
-
-
- has options =>
- (
- is => 'rw',
- isa => HashRef,
- default => sub { {} },
- lazy => 1,
- );
-
-
- has poe =>
- (
- is => 'ro',
- isa => Object,
- lazy_build => 1,
- );
-
- sub _build_poe
- {
- if(!defined $anonymous_poe)
- {
- $anonymous_poe = class
+ with 'POEx::Role::SessionInstantiation::Meta::Session::Magic';
+ with 'POEx::Role::SessionInstantiation::Meta::Session::Implementation';
+ with 'POEx::Role::SessionInstantiation::Meta::Session::Events';
+ with 'POEx::Role::SessionInstantiation::Meta::Session::Sugar';
+
+ # enable traits via import
+ method import (ClassName $role: ArrayRef :$traits?)
+ {
+ if(defined($traits))
+ {
+ my $tc = Tuple[RoleName, Optional[HashRef]];
+
+ unless($tc->validate($traits))
{
- use POEx::Types(':all');
- use MooseX::Types::Moose('Maybe', 'Str');
-
- has sender => ( is => 'rw', isa => Kernel|Session|DoesSessionInstantiation, clearer => 'clear_sender' );
- has state => ( is => 'rw', isa => Str, clearer => 'clear_state' );
- has file => ( is => 'rw', isa => Maybe[Str], clearer => 'clear_file' );
- has line => ( is => 'rw', isa => Maybe[Str], clearer => 'clear_line' );
- has from => ( is => 'rw', isa => Maybe[Str], clearer => 'clear_from' );
- has kernel => ( is => 'rw', isa => Kernel, clearer => 'clear_kernel' );
-
- method clear
- {
- $self->clear_sender;
- $self->clear_state;
- $self->clear_file;
- $self->clear_line;
- $self->clear_from;
- $self->clear_kernel;
- }
-
- method restore (Object $poe)
- {
- $self->sender($poe->sender);
- $self->state($poe->state);
- $self->file($poe->file);
- $self->line($poe->line);
- $self->from($poe->from);
- $self->kernel($poe->kernel);
- }
-
- method clone
- {
- return $self->meta->clone_object($self);
- }
- };
- }
-
- return $anonymous_poe->name->new();
- }
-
-
- has args =>
- (
- is => 'rw',
- isa => ArrayRef,
- default => sub { [] },
- lazy => 1
- );
-
-
- has alias =>
- (
- is => 'rw',
- isa => Str,
- trigger => sub
- {
- # we need to check to make sure we are currently in a POE context
- return if not defined($_[0]->poe->kernel);
- $POE::Kernel::poe_kernel->alias_set($_[1]);
- },
- clearer => '_clear_alias',
- );
-
-
- has ID =>
- (
- is => 'ro',
- isa => Int,
- default => sub { $POE::Kernel::poe_kernel->ID_session_to_id($_[0]) },
- lazy => 1,
- );
-
- # this just stores the anonymous clone class we create for our instance
- has _self_meta =>
- (
- is => 'rw',
- isa => 'Class::MOP::Class'
- );
- # add some sugar for posting, yielding, and calling events
- method post(SessionRefIdAliasInstantiation $session, Str $event_name, @args)
- {
- confess('No POE context') if not defined($self->poe->kernel);
- return $self->poe->kernel->post($session, $event_name, @args);
- }
-
- method yield(Str $event_name, @args)
- {
- confess('No POE context') if not defined($self->poe->kernel);
- return $self->poe->kernel->yield($event_name, @args);
- }
-
- method call(SessionRefIdAliasInstantiation $session, Str $event_name, @args)
- {
- confess('No POE context') if not defined($self->poe->kernel);
- return $self->poe->kernel->call($session, $event_name, @args);
- }
-
-
- # some defaults for _start, _stop and _default
- method _start(@args) is Event
- {
- if($self->alias)
- {
- # inside a poe context now, so fire the trigger
- $self->alias($self->alias);
- }
- 1;
- }
-
- method _stop() is Event
- {
- $self->clear_alias();
- 1;
- }
-
-
- method _default(ArrayRef $args?) is Event
- {
- my $string = defined($self->alias) ? $self->alias : $self->ID;
- my $state = $self->poe->state;
- warn "Nonexistent '$state' event delivered to $string";
- }
-
-
- method _child(Str $event, Session|DoesSessionInstantiation $child, Any $ret?) is Event
- {
- 1;
- }
-
-
- method _parent(Session|DoesSessionInstantiation|Kernel $previous_parent, Session|DoesSessionInstantiation|Kernel $new_parent) is Event
- {
- 1;
- }
-
- sub BUILD { 1; }
-
- after BUILD(@args)
- {
- #enable overload in the composed class (ripped from overload.pm)
- {
- no strict 'refs';
- no warnings 'redefine';
- ${$self->meta->name . "::OVERLOAD"}{dummy}++;
- *{$self->meta->name . "::()"} = sub {};
- }
-
- # we need a no-op bless here to activate the magic for overload
- bless ({}, $self->meta->name);
-
- #this registers us with the POE::Kernel
- $POE::Kernel::poe_kernel->session_alloc($self, @{$self->args()})
- if not $self->orig;
- };
-
- method clear_alias
- {
- $POE::Kernel::poe_kernel->alias_remove($self->alias());
- $self->_clear_alias();
- }
-
- method _invoke_state(Kernel|Session|DoesSessionInstantiation $sender, Str $state, ArrayRef $etc, Str $file?, Int $line?, Str $from?)
- {
- my $method = $self->meta()->find_method_by_name($state);
-
- if(defined($method))
- {
- if($method->isa('Class::MOP::Method::Wrapped'))
- {
- my $orig = $method->get_original_method;
- if(!$orig->meta->isa('Moose::Meta::Class') || !$orig->meta->does_role('POEx::Role::Event'))
- {
- POE::Kernel::_warn($self->ID, " -> $state [WRAPPED], called from $file at $line, exists, but is not marked as an available event");
- return;
- }
-
- }
- elsif(!$method->meta->isa('Moose::Meta::Class') || !$method->meta->does_role('POEx::Role::Event'))
- {
- POE::Kernel::_warn($self->ID, " -> $state, called from $file at $line, exists, but is not marked as an available event");
+ with $traits->[0], $traits->[1];
return;
}
- my $poe = $self->poe();
-
- my $saved;
- if(defined($poe->kernel))
+ foreach my $tuple (@$traits)
{
- $saved = $poe->clone();
+ my $ret = $tc->validate($tuple);
+ die $ret if defined($ret);
+ with $tuple->[0] => $tuple->[1];
}
-
- $poe->sender($sender);
- $poe->state($state);
- $poe->file($file);
- $poe->line($line);
- $poe->from($from);
- $poe->kernel($POE::Kernel::poe_kernel);
-
- POE::Kernel::_warn($self->ID(), " -> $state (from $file at $line)\n" )
- if $self->options->{trace};
-
- my $return = $method->execute($self, @$etc);
- $poe->clear();
- $poe->restore($saved) if defined $saved;
- return $return;
-
- }
- else
- {
- my $default = $self->meta()->find_method_by_name('_default');
-
- if(defined($default))
- {
- if($default->meta->isa('Class::MOP::Method::Wrapped'))
- {
- my $orig = $default->get_original_default;
- if(!$orig->meta->isa('Moose::Meta::Class') || !$orig->meta->does_role('POEx::Role::Event'))
- {
- POE::Kernel::_warn($self->ID, " -> $state [WRAPPED], called from $file at $line, exists, but is not marked as an available event");
- return;
- }
- }
- elsif(!$default->meta->isa('Moose::Meta::Class') || !$default->meta->does_role('POEx::Role::Event'))
- {
- POE::Kernel::_warn($self->ID, " -> $state, called from $file at $line, exists, but is not marked as an available event");
- return;
- }
- my $poe = $self->poe();
-
- my $saved;
- if(defined($poe->kernel))
- {
- $saved = $poe->clone();
- }
-
- $poe->sender($sender);
- $poe->state($state);
- $poe->file($file);
- $poe->line($line);
- $poe->from($from);
- $poe->kernel($POE::Kernel::poe_kernel);
-
- my $return = $default->execute($self, $etc);
- $poe->clear();
- $poe->restore($saved) if defined $saved;
- return $return;
- }
- else
- {
- my $loggable_self = defined($self->alias) ? $self->alias : $self->ID;
- POE::Kernel::_warn
- (
- "a '$state' event was sent from $file at $line to $loggable_self ",
- "but $loggable_self has neither a handler for it ",
- "nor one for _default\n"
- );
- }
- }
- }
-
- method _register_state (Str $method_name, CodeRef|MooseX::Method::Signatures::Meta::Method $coderef?, Str $ignore?)
- {
-
- # per instance changes
- $self = $self->_clone_self();
-
- if(!defined($coderef))
- {
- # we mean to remove this method
- $self->meta()->remove_method($method_name);
- }
- else
- {
- # horrible hack to make sure wheel states get called how they want to be called
- if($method_name =~ /POE::Wheel/)
- {
- $coderef = $self->_wheel_wrap_method($coderef);
- }
- # otherwise, it is either replace it or add it
- my $method = $self->meta()->find_method_by_name($method_name);
-
- if(defined($method))
- {
- $self->meta()->remove_method($method_name);
- }
-
- my ($new_method, $superclass);
-
- if(blessed($coderef) && $coderef->isa('MooseX::Method::Signatures::Meta::Method'))
- {
- $new_method = $coderef;
- $superclass = 'MooseX::Method::Signatures::Meta::Method';
-
- if($new_method->isa('Moose::Meta::Class') && $new_method->does_role(Event))
- {
- $self->meta->add_method($method_name, $new_method);
- return;
- }
-
- }
- else
- {
- $superclass = 'Moose::Meta::Method';
- $new_method = Moose::Meta::Method->wrap
- (
- $coderef,
- (
- name => $method_name,
- package_name => ref($self)
- )
- );
- }
-
- my $anon = Moose::Meta::Class->create_anon_class
- (
- superclasses => [ $superclass ],
- roles => [ Event ],
- cache => 1,
- );
-
- bless($new_method, $anon->name);
-
- $self->meta->add_method($method_name, $new_method);
-
- }
- }
-
- # we need this to insure that wheel states get called how they think they should be called
- # Note: this is a horrible hack.
- method _wheel_wrap_method (CodeRef|MooseX::Method::Signatures::Meta::Method $ref)
- {
- sub
- {
- my $obj = shift;
- my $poe = $obj->poe;
- my @args;
- (
- $args[OBJECT] ,
- $args[SESSION],
- $args[KERNEL],
- $args[HEAP],
- $args[STATE],
- $args[SENDER],
- $args[6],
- $args[CALLER_FILE],
- $args[CALLER_LINE],
- $args[CALLER_STATE],
- $args[ARG0],
- $args[ARG1],
- $args[ARG2],
- $args[ARG3],
- $args[ARG4],
- $args[ARG5],
- $args[ARG6],
- $args[ARG7],
- $args[ARG8],
- $args[ARG9],
- ) = ($obj, $obj, $poe->kernel, $obj->heap, $poe->state, $poe->sender, undef, $poe->file, $poe->line, $poe->from, @_);
-
- return $ref->(@args);
- }
- }
-
- method _clone_self
- {
- # we only need to clone once
- if($self->orig)
- {
- return $self;
- }
-
- # we need to hold on to the original stringification
- my $orig = "$self";
- $self->orig($orig);
-
- my $meta = $self->meta();
-
- $self->orig_name($meta->name);
-
- my $anon = Moose::Meta::Class->create_anon_class
- (
- superclasses => [ $meta->superclasses() ],
- methods => { map { $_->name, $_ } $meta->get_all_methods },
- attributes => [ $meta->get_all_attributes() ],
- );
-
- $anon->add_role($_) for @{$meta->roles};
-
- #enable overload in the anonymous class (ripped from overload.pm)
- {
- no strict 'refs';
- no warnings 'redefine';
- ${$anon->name . "::OVERLOAD"}{dummy}++;
- *{$anon->name . "::()"} = sub {};
- }
-
- my $stuff;
- # need to copy all of the symbols over
- foreach my $type (keys %{ $stuff = { SCALAR => '$', ARRAY => '@', HASH => '%', CODE => '&' } } )
- {
- my $symbols = $meta->get_all_package_symbols($type);
- foreach my $key (keys %$symbols)
- {
- if(!$anon->has_package_symbol($stuff->{$type} . $key))
- {
- if($type eq 'SCALAR')
- {
- $anon->add_package_symbol($stuff->{$type} . $key, ${$symbols->{$key}});
- }
- else
- {
- $anon->add_package_symbol($stuff->{$type} . $key, $symbols->{$key});
- }
-
- }
- }
- }
- # this bless not only reblesses into the anonymous class, but also activates overload
- bless($self, $anon->name);
-
- # and to keep our anonymous class from going out of scope, stash a reference into ourselves
- $self->_self_meta($anon);
-
- # And here is where we break POE encapsulation
- $POE::Kernel::poe_kernel->[POE::Kernel::KR_SESSIONS]->{$orig}->[POE::Kernel::SS_SESSION] = $self;
-
- return $self;
+ }
}
}
-
-
1;
@@ -515,11 +54,12 @@
=head1 VERSION
-version 0.092460
+version 0.092673
=head1 SYOPSIS
package My::Class;
+our $VERSION = '0.092673';
use 5.010;
use MooseX::Declare;
@@ -639,169 +179,126 @@
So please heed the warnings and don't blame me if this summons the terrasque
into your datacenter and you left your +5 gear at home.
-=head1 ATTRIBUTES
-
-=head2 heap is: rw, isa: Any, default: {}, lazy: yes
-
-A traditional POE::Session provides a set aside storage space for the session
-context and that space is provided via argument to event handlers. With this
-Role, your object gains its own heap storage via this attribute.
-
-=head2 options is: rw, isa: HashRef, default: {}, lazy: yes
-
-In following the POE::Session API, sessions can take options that do various
-things related to tracing and debugging. By default, tracing => 1, will turn on
-tracing of POE event firing to your object. debug => 1, currently does nothing
-but more object level tracing maybe enabled in future versions.
-
-
-
-=head2 poe is: ro, isa: Object
-
-The poe attribute provides runtime context for your object methods. It contains
-an anonymous object with it's own attributes and methods. Runtime context is
-built for each individual event handler invocation and then torn down to avoid
-context crosstalk. It is important to only access this attribute from within a
-POE invoked event handler.
-
-=head3 POE ATTRIBUTES
+=head1 FURTHER NOTES
+
+=head2 CUSTOMIZING VIA TRAITS
+
+POEx::Role::SessionInstantiation now allows for Trait declarations upon import.
+This is similar to how Moose itself allows for modification of its own Meta
+things through arguments passed to use (ie. use Moose -traits => qw /Foo/), but
+allows for parameterized roles. Below are some examples of using traits to
+modify POEx::Role::SessionInstantiation's default behavior.
+
+First let's declare a role that frobinates something at start:
+
+ use MooseX::Declare;
+
+ role FrobAtStart
+ {
+ with 'POEx::Role::SessionInstantiation::Meta::Session::Events';
+
+ has frobinator =>
+ (
+ is => 'ro',
+ isa => 'Object',
+ required => 1,
+ handles =>
+ {
+ 'frob' => 'frob'
+ }
+ );
+
+ after _start is POEx::Role::Event
+ {
+ $self->frob();
+ }
+ }
+
+And how about a logger role that logs unknown delivered events that wants the
+logging method/event to be a named parameter
+
+ role SomeLogger(Str :$foo)
+ {
+ with 'POEx::Role::SessionInstantiation::Meta::Session::Events';
+
+ has logger =>
+ (
+ is => 'ro',
+ isa => 'Object',
+ required => 1
+ );
+
+ method $foo(Str $event) is POEx::Role::Event
+ {
+ $self->logger->log("Unknown event: $event")
+ }
+
+ after _default is POEx::Role::Event
+ {
+ $self->$foo($self->poe->state);
+ }
+ }
+
+Now let's use them
+
+ class My::Session
+ {
+ # need to make sure these are loaded
+ use FrobinateAtStart;
+ use SomeLogger;
+
+ # and now the magic
+ use POEx::Role::SessionInstantiation
+ traits => [ ['FrobAtStart'], ['SomeLogger' => { foo => 'log' } ] ];
+
+ # compose it now that it has traits applied
+ with 'POEx::Role::SessionInstantiation';
+ ...
+ }
+
+And here is the import method signature:
+
+ method import (RoleName $role: ArrayRef :$traits?)
+
+Where $traits is expected to contain a series of Tuples that look like:
+
+ Tuple[RoleName, Optional[HashRef]]
+
+And there is a special case for a single trait where $traits is the tuple that
+is defined above. So the use statement above, if there is a single trait,
+could have been written as:
+
+ use POEx::Role::SessionInstantiation
+ traits => [ 'MyTrait' => { key => $args } ];
+
+=head2 WRITING YOUR OWN TRAITS
+
+To make it easy to advise just little parts of POEx::Role::SessionInstantiation
+it is broken down into a few different roles that you can 'with' like in the
+examples above.
=over 4
-=item sender is: rw, isa: POE::Kernel | POE::Session | ->does(SessionInstant.)
-
-The sender of the current event can be access from here. Semantically the same
-as $_[+SENDER].
-
-=item state is: rw, isa: Str
-
-The state fired. This should match the current method name (unless of course
-within the _default event handler, then it will be the event name that was
-invoked but did not exist in your object instance.
-
-=item [qw/file line from/] is: rw, isa: Maybe[Str]
-
-These attributes provide tracing information from within POE. From is actually
-not used in POE::Session as far as I can tell, but it is available just in
-case.
-
-=item kernel is: rw, isa: POE::Kernel
-
-This is actually the POE::Kernel singleton provided as a little sugar instead
-of requiring use of $poe_kernel, etc. To make sure you are currently within a
-POE context, check this attribute for definedness.
+=item POEx::Role::SessionInstantiation::Meta::Session::Magic
+
+This is where the voodoo happens to turn your objects into sessions.
+
+=item POEx::Role::SessionInstantiation::Meta::Session::Events
+
+Here are the default events such as _start, _stop, _default, etc.
+
+=item POEx::Role::SessionInstantiation::Meta::Session::Sugar
+
+This role holds the delegated methods from POE::Kernel (post, yield, call)
+
+=item POEx::Role::SessionInstantiation::Meta::Session::Implementation
+
+And this is the implementation piece that implements the POE::Session
+interface that lets POE interact with our sessions
=back
-=head3 POE PRIVATE METHODS
-
-=over 4
-
-=item clear()
-
-This will clear the all of the current context information.
-
-=item restore($poe)
-
-This will take another anonymous poe object and restore state.
-
-=item clone()
-
-This will clone the current anonymous poe object and return it.
-
-=back
-
-
-
-=head2 args is: rw, isa: ArrayRef, default: [], lazy: yes
-
-POE::Session's constructor provides a mechanism for passing arguments that will
-end up as arguments to the _start event handler. This is the exact same thing.
-
-
-
-=head2 alias is: rw, isa: Str, clearer: clear_alias, trigger: registers alias
-
-This attribute controls your object's alias to POE. POE allows for more than
-one alias to be assigned to any given session, but this attribute only assumes
-a single alias will not attempt to keep track of all the aliases. Last alias
-set will be what is returned. Calling the clearer will remove the last alias
-set from POE and unset it. You must be inside a valid POE context for the
-trigger to actually fire (ie, inside a event handler that has been invoked from
-POE). While this can be set at construction time, it won't be until _start that
-it will actually register with POE. If you override _start, don't forget to set
-this attribute again ( $self->alias($self->alias); ) or else your alias will
-never get registered with POE.
-
-
-
-=head2 ID is: ro, isa: Int
-
-This attribute will return what your POE assigned Session ID is. Must only be
-accessed after your object has been fully built (ie. after any BUILD methods).
-This ID can be used, in addition to a reference to yourself, and your defined
-alias, by other Sessions for addressing events sent through POE to your object.
-
-
-
-=head1 METHODS
-
-=head2 [qw/post yield call/]
-
-These are provided as sugar for the respective POE::Kernel methods.
-
-
-
-=head2 _start(@args)
-
-Provides a default _start event handler that will be invoked from POE once the
-Session is registered with POE. The default method only takes the alias
-attribute and sets it again to activate the trigger. If this is overridden,
-don't forget to set the alias again so the trigger can execute.
-
-
-
-=head2 _stop()
-
-Provides a default _stop event handler that will be invoked from POE once the
-Session's refcount from within POE has reached zero (no pending events, no
-event sources, etc). The default method merely clears out the alias.
-
-
-
-=head2 _default(ArrayRef $args)
-
-Provides a _default event handler to catch any POE event invocations that your
-instance does not actually have. Will 'warn' about the nonexistent state. A big
-difference from POE::Session is that the state and arguments are not rebundled
-upon invocation of this event handler. Instead the attempted state will be
-available in the poe attribute, but the arguments are still bundled into a
-single ArrayRef
-
-
-
-=head2 _child(Str $event, Session $child, Any $ret?)
-
-Provides a _child event handler that will be invoked when child sesssions are
-created, destroyed or reassigned to or from another parent. See POE::Kernel for
-more details on this event and its semantics
-
-
-
-=head2 _parent(Session $previous_parent, Session $new_parent)
-
-Provides a _parent event handler. This is used to notify children session when
-their parent has changes. See POE::Kernel for more details on this event.
-
-
-
-=head2 after BUILD
-
-All of the magic for turning the constructed object into a Session happens in
-this method. If a BUILD is not provided, a stub exists to make sure this advice
-is executed.
-
-
+Please see their POD for more details on the inner workings of this module.
=head1 AUTHOR
Modified: trunk/libpoex-role-sessioninstantiation-perl/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpoex-role-sessioninstantiation-perl/t/00-load.t?rev=45395&op=diff
==============================================================================
--- trunk/libpoex-role-sessioninstantiation-perl/t/00-load.t (original)
+++ trunk/libpoex-role-sessioninstantiation-perl/t/00-load.t Mon Oct 5 19:39:51 2009
@@ -1,4 +1,9 @@
use Test::More;
+use_ok( 'POEx::Role::SessionInstantiation::Meta::Session::Magic' );
+use_ok( 'POEx::Role::SessionInstantiation::Meta::Session::Events' );
+use_ok( 'POEx::Role::SessionInstantiation::Meta::Session::Sugar' );
+use_ok( 'POEx::Role::SessionInstantiation::Meta::Session::Implementation' );
use_ok( 'POEx::Role::SessionInstantiation' );
+
done_testing();
Modified: trunk/libpoex-role-sessioninstantiation-perl/t/01-basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpoex-role-sessioninstantiation-perl/t/01-basic.t?rev=45395&op=diff
==============================================================================
--- trunk/libpoex-role-sessioninstantiation-perl/t/01-basic.t (original)
+++ trunk/libpoex-role-sessioninstantiation-perl/t/01-basic.t Mon Oct 5 19:39:51 2009
@@ -42,7 +42,8 @@
}
method blat is Event
{
- Test::More::pass('blat called');
+ Test::More::pass('blat called');
+ $self->clear_alias;
}
}
@@ -55,7 +56,8 @@
use aliased 'POEx::Role::Event';
method flarg is Event
{
- Test::More::pass('flarg called');
+ Test::More::pass('flarg called');
+ $self->clear_alias;
}
before _stop is Event
{
More information about the Pkg-perl-cvs-commits
mailing list