Make the private object constructor handle inheritance.

Fix a POD typo.
This commit is contained in:
Colin Kuskie 2008-02-25 22:04:40 +00:00
parent 26d708a56b
commit 6d856d1b58

View file

@ -44,9 +44,9 @@ Private method used to build objects, shared by new and create.
=cut =cut
sub _buildObj { sub _buildObj {
my ($class, $session, $shipperId, $options) = @_; my ($class, $session, $requestedClass, $shipperId, $options) = @_;
my $self = {}; my $self = {};
bless $self, $class; bless $self, $requestedClass;
register $self; register $self;
my $id = id $self; my $id = id $self;
@ -54,7 +54,7 @@ sub _buildObj {
$session{ $id } = $session; $session{ $id } = $session;
$shipperId{ $id } = $shipperId; $shipperId{ $id } = $shipperId;
$options{ $id } = $options; $options{ $id } = $options;
$className{ $id } = $class; $className{ $id } = $requestedClass;
return $self; return $self;
} }
@ -106,7 +106,7 @@ sub create {
croak "You must pass a hashref of options to create a new ShipDriver object" croak "You must pass a hashref of options to create a new ShipDriver object"
unless defined($options) and ref $options eq 'HASH' and scalar keys %{ $options }; unless defined($options) and ref $options eq 'HASH' and scalar keys %{ $options };
my $shipperId = $session->id->generate; my $shipperId = $session->id->generate;
my $self = WebGUI::Shop::ShipDriver->_buildObj($session, $shipperId, $options); my $self = WebGUI::Shop::ShipDriver->_buildObj($session, $class, $shipperId, $options);
$session->db->write('insert into shipper (shipperId,className) VALUES (?,?)', [$shipperId, $class]); $session->db->write('insert into shipper (shipperId,className) VALUES (?,?)', [$shipperId, $class]);
$self->set($options); $self->set($options);
@ -201,6 +201,7 @@ sub get {
Dynamically generate an HTMLForm based on the contents Dynamically generate an HTMLForm based on the contents
of the definition sub, and return the form. of the definition sub, and return the form.
=cut =cut
sub getEditForm { sub getEditForm {
@ -271,7 +272,7 @@ sub new {
croak "Somehow, the options property of this object, $shipperId, got broken in the db" croak "Somehow, the options property of this object, $shipperId, got broken in the db"
unless exists $properties->{options} and $properties->{options}; unless exists $properties->{options} and $properties->{options};
my $options = from_json($properties->{options}); my $options = from_json($properties->{options});
my $self = WebGUI::Shop::ShipDriver->_buildObj($session, $shipperId, $options); my $self = WebGUI::Shop::ShipDriver->_buildObj($session, $class, $shipperId, $options);
return $self; return $self;
} }