Solo has asked for the wisdom of the Perl Monks concerning the following question:
From POD:
object_list
Functions like list, but maintains an array of referenced objects in each slot. Forwarded methods return a list of the results returned by maping the method over each object in the array.
Arguments are like object.
Output:use strict; use Class::MethodMaker "-sugar"; package MyPackage::Item; make methods new_hash_init => 'new', get_set => [qw/ name /], ; # make methods package MyPackage::List; make methods new_hash_init => 'new', object_list => [ MyPackage::Item => { slot => 'items', comp_mthds => [qw/ name /], }, ], ; package main; use Data::Dumper; my $list = MyPackage::List->new(); $list->items_push( MyPackage::Item->new(name=>'test1') ); print Dumper($list); # POD says this should return a list from a map # of the forwarded methods over all objects in # the list, but I can't get it to work! print $list->items->name;
$VAR1 = bless( { 'items' => [ bless( { 'name' => 'test1' }, 'MyPackage::Item' ) ] }, 'MyPackage::List' ); Can't call method "name" on unblessed reference at test.pl line 32.
--
The ability to destroy planets is insignificant next to the power of the Deacon Effect.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
How to 'Do The Work' (was Re: Class::MethodMaker object_list help needed)
by Solo (Deacon) on Feb 03, 2003 at 19:35 UTC | |
by simonm (Vicar) on Sep 15, 2003 at 18:36 UTC |