Move WebGUI::Friends over to Moose from Class::InsideOut
This commit is contained in:
parent
c687ec6917
commit
97b6a58597
1 changed files with 28 additions and 13 deletions
|
|
@ -16,6 +16,20 @@ package WebGUI::Friends;
|
|||
|
||||
use strict;
|
||||
use Class::InsideOut qw(id register public readonly);
|
||||
|
||||
use Moose;
|
||||
|
||||
has 'session' => (
|
||||
is => 'ro',
|
||||
required => 1,
|
||||
weak_ref => 1,
|
||||
);
|
||||
|
||||
has 'user' => (
|
||||
is => 'ro',
|
||||
required => 1,
|
||||
);
|
||||
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::HTML;
|
||||
use WebGUI::Inbox;
|
||||
|
|
@ -23,9 +37,6 @@ use WebGUI::International;
|
|||
use WebGUI::User;
|
||||
use WebGUI::Utility;
|
||||
|
||||
readonly session => my %session;
|
||||
readonly user => my %user;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Friends
|
||||
|
|
@ -45,6 +56,20 @@ A user relationship management system.
|
|||
|
||||
=cut
|
||||
|
||||
around BUILDARGS => sub {
|
||||
my $orig = shift;
|
||||
my $className = shift;
|
||||
|
||||
##Original arguments start here.
|
||||
my $protoSession = $_[0];
|
||||
if (blessed $protoSession && $protoSession->isa('WebGUI::Session')) {
|
||||
my $protoUser = defined $_[1] ? $_[1] : $protoSession->user;
|
||||
return $className->$orig(session => $protoSession, user => $protoUser,);
|
||||
}
|
||||
return $className->$orig(@_);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -276,16 +301,6 @@ attached to the session.
|
|||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $user = shift || $session->user;
|
||||
my $self = register($class);
|
||||
$session{id $self} = $session;
|
||||
$user{id $self} = $user;
|
||||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 rejectAddRequest ( inviteId[,sendNotification] )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue