SPUG:Object property question

Dan Ebert mathin at mathin.com
Wed Apr 30 17:24:01 CDT 2003


The Setup:

I'm working on a module to manage a membership database.  I have it set
up so that there is a Member object with properties you can access like

my $firstname = $member->firstname();

and change with

$member->firstname('new first name');

etc.

when a new member is created:

$member->initialize(firstname => 'John',
                    lastname  => 'Doe');
$member->create();

I insert the data into a table and get the member ID from an
auto-incrementing field.

The Question:

I want to set a new property of the Member object (the ID).  So that you
can retrieve the ID with 

$id = $member->id();

In my module I tried: 

$member->{id} = $id

but that didn't work.

The only thing I've gotten to work is to return the object ... so that
you call the create method like this:

$member = $member->create();

which seems a little awkward.

Is there a better way?

-- 
Dan Ebert      <mathin at mathin.com>
-------------------------------------------------------------
Frisbeetarianism (n.), The belief that, when you die, your 
soul goes up on the roof and gets stuck there.



More information about the spug-list mailing list