X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=site_perl%2Ftable_template.pm;h=0173bc5cf17faa2f7ece833417274a2fb5ec3a62;hb=1e3eae905b861761f93643aa5fce14a8be5d9ed2;hp=5b560a2e71890036403c8a764de49ddaa245b828;hpb=71825c330729668bfa658a0203b0e3cb8362a4f9;p=freeside.git diff --git a/site_perl/table_template.pm b/site_perl/table_template.pm index 5b560a2e7..0173bc5cf 100644 --- a/site_perl/table_template.pm +++ b/site_perl/table_template.pm @@ -1,10 +1,8 @@ package FS::table_name; use strict; -use vars qw (@ISA); -use Exporter; -#use FS::UID qw(getotaker); -use FS::Record qw(hfields qsearch qsearchs); +use vars qw( @ISA ); +use FS::Record qw( qsearch qsearchs ); @ISA = qw(FS::Record); @@ -16,8 +14,8 @@ FS::table_name - Object methods for table_name records use FS::table_name; - $record = create FS::table_name \%hash; - $record = create FS::table_name { 'column' => 'value' }; + $record = new FS::table_name \%hash; + $record = new FS::table_name { 'column' => 'value' }; $error = $record->insert; @@ -42,7 +40,7 @@ FS::Record. The following fields are currently supported: =over 4 -=item create HASHREF +=item new HASHREF Creates a new example. To add the example to the database, see L<"insert">. @@ -51,12 +49,9 @@ points to. You can ask the object for a copy with the I method. =cut -sub create { - my($proto,$hashref)=@_; +# the new method can be inherited from FS::Record, if a table method is defined - $proto->new('table_name',$hashref); - -} +sub table { 'table_name'; } =item insert @@ -65,19 +60,7 @@ otherwise returns false. =cut -sub insert { - my($self)=@_; - - #local $SIG{HUP} = 'IGNORE'; - #local $SIG{INT} = 'IGNORE'; - #local $SIG{QUIT} = 'IGNORE'; - #local $SIG{TERM} = 'IGNORE'; - #local $SIG{TSTP} = 'IGNORE'; - - $self->check or - $self->add; -} - +# the insert method can be inherited from FS::Record =item delete @@ -85,11 +68,7 @@ Delete this record from the database. =cut -sub delete { - my($self)=@_; - - $self->del; -} +# the delete method can be inherited from FS::Record =item replace OLD_RECORD @@ -98,41 +77,38 @@ returns the error, otherwise returns false. =cut -sub replace { - my($new,$old)=@_; - return "(Old) Not a table_name record!" unless $old->table eq "table_name"; - - return "Can't change keyfield!" - unless $old->getfield('keyfield') eq $new->getfield('keyfield'); - - $new->check or - $new->rep($old); -} - +# the replace method can be inherited from FS::Record =item check Checks all fields to make sure this is a valid example. If there is an error, returns the error, otherwise returns false. Called by the insert -and repalce methods. +and replace methods. =cut -sub check { - my($self)=@_; - return "Not a table_name record!" unless $self->table eq "table_name"; +# the check method should currently be supplied - FS::Record contains some +# data checking routines +sub check { + my $self = shift; ''; #no error } +=back + +=head1 VERSION + +$Id: table_template.pm,v 1.4 1998-12-29 11:59:57 ivan Exp $ + =head1 BUGS The author forgot to customize this manpage. =head1 SEE ALSO -L +L, schema.html from the base documentation. =head1 HISTORY @@ -142,7 +118,13 @@ added hfields ivan@sisd.com 97-nov-13 $Log: table_template.pm,v $ -Revision 1.2 1998-11-15 03:48:49 ivan +Revision 1.4 1998-12-29 11:59:57 ivan +mostly properly OO, some work still to be done with svc_ stuff + +Revision 1.3 1998/11/15 04:33:00 ivan +updates for newest versoin + +Revision 1.2 1998/11/15 03:48:49 ivan update for current version