On Mon, Apr 30, 2007 at 05:05:00PM -0400, Dan Boger wrote:
> sub new {
> my ($self, $attrs) = @_;
WRONG!
my ($class, $attrs) = @_;
It's not an object yet, it's a class. always say $class in constructor,
because ...
>
> $attrs->{unixtime} = time if not $attrs->{unixtime} or
> $attrs->{unixtime} =~ /\D/;
> $attrs->{date} = sprintf("%04d-%02d-%02d", (localtime)[5]+1900,
> (localtime)[4]+1, (localtime)[3])
> unless $attrs->{date} and $attrs->{date} =~ /^\d\d\d\d-\d\d-\d\d$/;
>
> $self->next::method($attrs);
Then you won't forget to make this line
my $self = $class->next::method($attrs);
:)
> return $self;
> }
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director Want a managed development or deployment platform?
Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
http://www.shadowcatsystems.co.uk/
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/