GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CLASS::OBJECTTEMPLATE::DB (3)

.ds Aq ’

NAME

Class::ObjectTemplate:DB - Perl extension for an optimized template builder base class with lookup capability.

CONTENTS

SYNOPSIS



  package Foo;
  use Class::ObjectTemplate::DB;
  require Exporter;
  @ISA = qw(Class::ObjectTemplate:DB Exporter);

  attributes(lookup => [one, two], no_lookup => [three]);

  $foo = Foo->new();

  # these two invocations can trigger lookup
  $val = $foo->one();
  $val = $foo->two();

  # this invocation will not trigger lookup
  $val = $foo->three();

  # undefined() handles lookup
  sub Foo::undefined {
    my ($self,$attr) = @_;

    # we retrieve $attr from DB
    return DB_Lookup($self,$attr);
  }



DESCRIPTION

Class::ObjectTemplate::DB extends Class::ObjectTemplate in one simple way: the undefined() method.

When a class that inherits from Class::ObjectTemplate::DB defines a method called undefined(), that method will be triggered when an attribute\’s getter method is invoked and the attribute\’s current value is undef.

The author finds this useful when representing classes based on objects stored in databases (hence the name of the module). That way an object can be created, without triggering a DB lookup. Later if data is accessed and it is not currently present in the object, it can be retrieved on an as-need basis.

    METHODS

attributes(’attr1’, ’attr2’)
attributes(lookup => [’attr1’], no_lookup => [’attr2’]) attributes() still supports the standard Class::ObjectTemplate syntax of a list of attribute names.

To use the new functionality, the new key-value syntax must be used. Any method names specified in the lookup array, will trigger undefined. Those specified in the no_lookup will not trigger undefined().

undefined($self, $attr_name) A class that inherits from Class::ObjectTemplate::DB must define a method called undefined() in order to utilize the lookup behavior.

Whenever an attribute\’s getter method is invoked, and that attribute\’s value is currently undef, then undefined() will be invoked if that attribute was defined as in the lookup array when attributes() was called.

A class\’s undefined() method can include any specialized code needed to lookup the value for that objects\’s attribute, such as using DBI to connect to a local DB, and retrieve the value from a table.

Class::ObjectTemplate::DB defines a default undefined() which does nothing.

    EXPORT

attributes()

AUTHOR

Jason E. Stewart (jason@openinformatics.com)

SEE ALSO

perl(1).

POD ERRORS

Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 223: ’=item’ outside of any ’=over’
Around line 225: You forgot a ’=back’ before ’=head1’
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 DB (3) 2002-02-25

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.