Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

changed syntax of BaseModel constructor (samples broken)

  • Loading branch information...
commit 73e4c6622f4cea6a8a8b1946bcc3ef4e34482e22 1 parent df465cc
Michael Harris authored
Showing with 17 additions and 6 deletions.
  1. +17 −6 lib/MVCimple/BaseModel.pm
23 lib/MVCimple/BaseModel.pm
View
@@ -31,12 +31,22 @@ use MVCimple::Types; #use all datatypes
sub new {
- my ($class,$name,$model,$models) = @_;
- my $self = {'name' => $name};
- $self->{'columns'} = {};
-
- #Go though each of the model elements and bless along with returning the constructor;
- while( my($column_name,$modelcolumn) = each(%{$model}))
+ my ($class,$params) = @_;
+
+ my $name = $params->{'object_name'};
+ my $model_name = $params->{'model'};
+ my $models = $params->{'models'};
+
+ my $model = $models->{$model_name};
+
+ #print Dumper($model); #DEBUG
+
+ my $self = {};
+ $self->{'name'} = $name;
+ $self->{'columns'} = {};
+
+ #Go though each of the model elements and bless along with returning the constructor;
+ while( my($column_name,$modelcolumn) = each(%{$model}))
{
# mirror the attirbutes of a foreign key column, if applicable
my $FOREIGN_KEY = lc $modelcolumn->{"foreign_key"};
@@ -55,6 +65,7 @@ sub new {
bless $self->{'columns'}->{$column_name},"MVCimple::$modelcolumn->{type}";
$self->{'columns'}->{$column_name} = $self->{'columns'}->{$column_name}->new($column_name,$modelcolumn);
}
+
bless $self;
return $self;
}#end new (constructor)
Please sign in to comment.
Something went wrong with that request. Please try again.