From: Brian Cassidy Date: Mon, 19 Dec 2005 20:19:14 +0000 (+0000) Subject: added cookbook example: setting default values X-Git-Tag: v0.05005~128 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a00e1684b40b87ab2af2f8fe2a3ee978f38a0e85;p=dbsrgits%2FDBIx-Class.git added cookbook example: setting default values --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 48edc40..9bdd280 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -110,4 +110,16 @@ illustrate: # book2author table equals the bookID of the books (using the bookID # relationship table +=head2 Setting default values + +It's as simple as overriding the C method. Note the use of C. + + sub new { + my( $class, $attrs ) = @_; + + $attrs->{ foo } = 'bar' unless defined $attrs->{ foo }; + + $class->next::method( $attrs ); + } + =back