From: Matt Sickler Date: Fri, 29 Apr 2011 17:58:32 +0000 (-0500) Subject: Tweaked example code for having non-db data accessors. X-Git-Tag: v0.08191~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=458c16510455a7bd48c6e010bd1da1fb6e2c77e8;p=dbsrgits%2FDBIx-Class.git Tweaked example code for having non-db data accessors. --- diff --git a/lib/DBIx/Class/Manual/FAQ.pod b/lib/DBIx/Class/Manual/FAQ.pod index 4a9eb18..ba6d4d1 100644 --- a/lib/DBIx/Class/Manual/FAQ.pod +++ b/lib/DBIx/Class/Manual/FAQ.pod @@ -473,25 +473,25 @@ Invoked like this: =item How do I store my own (non-db) data in my DBIx::Class objects? -You can add your own data accessors to your classes. +You can add your own data accessors to your Result classes. One method is to use the built in mk_group_accessors (via L) - package MyTable; + package App::Schema::Result::MyTable; - use parent 'DBIx::Class'; + use parent 'DBIx::Class::Core'; __PACKAGE__->table('foo'); #etc __PACKAGE__->mk_group_accessors('simple' => qw/non_column_data/); # must use simple group An another method is to use L with your L package. - package MyTable; + package App::Schema::Result::MyTable; use Moose; # import Moose use Moose::Util::TypeConstraint; # import Moose accessor type constraints - extends 'DBIx::Class'; # Moose changes the way we define our parent (base) package + extends 'DBIx::Class::Core'; # Moose changes the way we define our parent (base) package has 'non_column_data' => ( is => 'rw', isa => 'Str' ); # define a simple attribute