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 (3)

.ds Aq ’

NAME

Class::ObjectTemplate - Perl extension for an optimized template builder base class.

CONTENTS

SYNOPSIS



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

  attributes(one, two, three);

  # initialize will be called by new()
  sub initialize {
    my $self = shift;
    $self->three(1) unless defined $self->three();
  }

  use Foo;
  $foo = Foo->new();

  # store 27 in the one attribute
  $foo->one(27);

  # check the value in the two attribute
  die "should be undefined" if defined $foo->two();

  # set using the utility method
  $foo->set_attribute(one,27);

  # check using the utility method
  $two = $foo->get_attribute(two);

  # set more than one attribute using the named parameter style
  $foo->set_attributes(one=>27, two=>42);

  # or using array references
  $foo->set_attributes([one,two],[27,42]);

  # get more than one attribute
  @list = $foo->get_attributes(one, two);

  # get a list of all attributes known by an object
  @attrs = $foo->get_attribute_names();

  # check that initialize() is called properly
  die "initialize didnt set three()" unless $foo->three();



DESCRIPTION

Class::ObjectTemplate is a utility class to assist in the building of other Object Oriented Perl classes.

It was described in detail in the O\’Reilly book, Advanced Perl Programming by Sriram Srinivasam.

    EXPORT

attributes(@name_list)

This method creates a shared setter and getter methods for every name in the list. The method also creates the class constructor, new().

<B>WARNINGB>: This method must be invoked within the module for every class that inherits from Class::ObjectTemplate, even if that class defines no attributes. For a class defining no new attributes, it should invoke attributes() with no arguments.

AUTHOR

Original code by Sriram Srinivasam.

Fixes and CPAN module by Jason E. Stewart (jason@openinformatics.com)

SEE ALSO

http://www.oreilly.com/catalog/advperl/

perl(1).

Class::ObjectTemplate::DB

Search for    or go to Top of page |  Section 3 |  Main Index


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

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