Permalink
Browse files

changed syntax of BaseModel constructor (samples broken)

  • Loading branch information...
1 parent df465cc commit 73e4c6622f4cea6a8a8b1946bcc3ef4e34482e22 @shiftycow committed Aug 2, 2011
Showing with 17 additions and 6 deletions.
  1. +17 −6 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)

0 comments on commit 73e4c66

Please sign in to comment.