forked from vti/pocketio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It is possible to pass class name and method instead of inline handler
- Loading branch information
vti
committed
Apr 9, 2011
1 parent
31817b4
commit f53a7cd
Showing
3 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package Handler; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
sub new { | ||
my $class = shift; | ||
|
||
return bless {}, $class; | ||
} | ||
|
||
sub run { | ||
my $self = shift; | ||
|
||
return sub { | ||
}; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use lib 't/lib'; | ||
|
||
use Test::More tests => 4; | ||
|
||
use_ok('Plack::Middleware::SocketIO'); | ||
|
||
eval { | ||
Plack::Middleware::SocketIO->new(app => sub { }); | ||
}; | ||
like $@ => qr/Either 'handler' or 'class' must be specified/; | ||
|
||
my $middleware = | ||
Plack::Middleware::SocketIO->new(app => sub { }, handler => sub { }); | ||
is ref($middleware->handler) => 'CODE'; | ||
|
||
$middleware = | ||
Plack::Middleware::SocketIO->new(app => sub { }, class => 'Handler'); | ||
is ref($middleware->handler) => 'CODE'; |