Update Shop::Ship to use Moose instead of C::IO. Update tests, and core code. Provide a shim for the old syntax.
This commit is contained in:
parent
9678c3d8a7
commit
6ac0aa936c
4 changed files with 30 additions and 51 deletions
|
|
@ -199,7 +199,7 @@ sub www_ship {
|
|||
my $session = shift;
|
||||
my $output = undef;
|
||||
my $method = "www_".$session->form->get("method");
|
||||
my $ship = WebGUI::Shop::Ship->new($session);
|
||||
my $ship = WebGUI::Shop::Ship->new(session => $session);
|
||||
if ($method ne "www_" && $ship->can($method)) {
|
||||
$output = $ship->$method($session);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ Returns the WebGUI::Shop::ShipDriver object that is attached to this cart for sh
|
|||
|
||||
sub getShipper {
|
||||
my $self = shift;
|
||||
return WebGUI::Shop::Ship->new($self->session)->getShipper($self->get("shipperId"));
|
||||
return WebGUI::Shop::Ship->new(session => $self->session)->getShipper($self->get("shipperId"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -845,7 +845,7 @@ sub www_view {
|
|||
else {
|
||||
$var{hasShippingAddress} = 1;
|
||||
$var{shippingAddress} = $address->getHtmlFormatted;
|
||||
my $ship = WebGUI::Shop::Ship->new($self->session);
|
||||
my $ship = WebGUI::Shop::Ship->new(session => $self->session);
|
||||
my $options = $ship->getOptions($self);
|
||||
my $numberOfOptions = scalar keys %{ $options };
|
||||
if ($numberOfOptions < 1) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package WebGUI::Shop::Ship;
|
|||
|
||||
use strict;
|
||||
|
||||
use Class::InsideOut qw{ :std };
|
||||
use Moose;
|
||||
use WebGUI::Exception;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Pluggable;
|
||||
|
|
@ -28,7 +28,25 @@ These subroutines are available from this package:
|
|||
|
||||
=cut
|
||||
|
||||
readonly session => my %session;
|
||||
has session => (
|
||||
is => 'ro',
|
||||
required => 1,
|
||||
);
|
||||
|
||||
around BUILDARGS => sub {
|
||||
my $orig = shift;
|
||||
my $className = shift;
|
||||
|
||||
##Original arguments start here.
|
||||
if (ref $_[0] eq 'HASH') {
|
||||
return $className->$orig(@_);
|
||||
}
|
||||
my $protoSession = $_[0];
|
||||
if (blessed $protoSession && $protoSession->isa('WebGUI::Session')) {
|
||||
return $className->$orig(session => $protoSession);
|
||||
}
|
||||
return $className->$orig(@_);
|
||||
};
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -163,28 +181,6 @@ sub getShippers {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( $session )
|
||||
|
||||
Constructor.
|
||||
|
||||
=head3 $session
|
||||
|
||||
A WebGUI::Session object.
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
WebGUI::Error::InvalidObject->throw(expected=>"WebGUI::Session", got=>(ref $session), error => q{Must provide a session variable}) unless ref $session eq 'WebGUI::Session';
|
||||
my $self = register $class;
|
||||
my $id = id $self;
|
||||
$session{ $id } = $session;
|
||||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 session ()
|
||||
|
||||
Returns a reference to the current session.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue