in reply to Re: Setting common object attributes
in thread Setting common object attributes
Thanks! I've mostly followed this, but, being too lazy to write out each sub call, put them all in a foreach loop:
sub load_defaults_for_model { my ($self) = @_; my $model = $self->defaults(); if ( defined( $model )) { foreach my $attrib (keys %{ $model }) { $self->$attrib( $model->{$attrib} ); } } }
The $self->defaults() method currently just pulls a hash from a master hash, but I'll make it use a database when I get that far :-)
|
|---|