clinton has asked for the wisdom of the Perl Monks concerning the following question:
I have an Object base class which is inherited by other objects eg User, Group, Image. When each of these is loaded, they register their Type with the Object class so that any object can be retrieved using the parent class and blessed into the right package.
An Object can never exist on its own - it must always be blessed into a child class.sub find { my $object = __PACKAGE__->retrieve_object($id); bless $object,$object->type->class
Group is a child class, and any object (including Groups) can be a member of a Group. Also, every object has a default Group (eg User automatically belongs to the group all_users).
Requirements
Then in the package Group:use Group 'default_group'
Is this good, bad, ugly? Beauty, truth and love appreciatedsub import { my $default_group = $_[1]; my $callpkg = caller(0); register_default_group($callpkg,$default_group); no strict 'refs'; *{$callpkg."::groups"} = \&groups; use strict;
thanks
clint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using perl 6 roles in perl 5
by dragonchild (Archbishop) on Jan 18, 2006 at 14:50 UTC | |
by clinton (Priest) on Jan 18, 2006 at 15:22 UTC | |
by dragonchild (Archbishop) on Jan 18, 2006 at 15:26 UTC | |
by clinton (Priest) on Jan 18, 2006 at 18:44 UTC | |
by dragonchild (Archbishop) on Jan 18, 2006 at 19:06 UTC | |
|
Re: Using perl 6 roles in perl 5
by stvn (Monsignor) on Jan 18, 2006 at 15:03 UTC | |
by clinton (Priest) on Jan 18, 2006 at 15:32 UTC |