From 3807197cbb86b35516cc09770f172803990d7451 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 2 Jul 2010 16:43:59 -0700 Subject: [PATCH] Move WebGUI::Shop::Admin from Class::InsideOut over to Moose. --- lib/WebGUI/Shop/Admin.pm | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/WebGUI/Shop/Admin.pm b/lib/WebGUI/Shop/Admin.pm index 3bae3354d..5279990ad 100644 --- a/lib/WebGUI/Shop/Admin.pm +++ b/lib/WebGUI/Shop/Admin.pm @@ -1,7 +1,27 @@ package WebGUI::Shop::Admin; use strict; -use Class::InsideOut qw{ :std }; + +use Moose; + +has session => ( + is => 'ro', + required => 1, +); + +around BUILDARGS => sub { + my $orig = shift; + my $className = shift; + + ##Original arguments start here. + my $protoSession = $_[0]; + if (blessed $protoSession && $protoSession->isa('WebGUI::Session')) { + return $className->$orig(session => $protoSession); + } + return $className->$orig(@_); +}; + + use WebGUI::AdminConsole; use WebGUI::Exception::Shop; use WebGUI::HTMLForm; @@ -28,8 +48,6 @@ These subroutines are available from this package: =cut -readonly session => my %session; - #------------------------------------------------------------------- =head2 canManage ( [ $user ] ) @@ -103,17 +121,6 @@ A reference to the current session. =cut -sub new { - my ($class, $session) = @_; - unless (defined $session && $session->isa("WebGUI::Session")) { - WebGUI::Error::InvalidObject->throw(expected=>"WebGUI::Session", got=>(ref $session), error=>"Need a session."); - } - my $self = register $class; - my $id = id $self; - $session{ $id } = $session; - return $self; -} - #------------------------------------------------------------------- =head2 session ()