I suspect what you’re looking for is a helper class which your parent class accesses via a HASA or USES relationship. But in the absence of concrete details it’s hard to give more definite advice.
Yes, that is essentially what I'm trying to do.
Specifically, I'm working on an API for Samba 4 Active Directory using Net::LDAP. The API is meant to abstract much of the LDAP code needed to query the AD. For example, you could ask the api:
@posix_users = $ad->listObjects('users','posix');And then the API would spit out the requested data. The problem I was running into is that the over all perl module was getting large in size, so I thought I'd try and spin off some of the methods to sub-classes. Good examples are those methods associated with users would get a module: Users.pm. And then those associated with groups, Groups.pm.
So my module structure looks like this:
esmith::AD (AD.pm) The methods in Users.pm and Groups.pm really do specialize active directory objects generated in the parent module. Following your example, a user ISA object.
So the primary reason for wanting the parent class to see the child class methods, we me being lazy, I think.
Lazy Code (child method called from parent constructor): use esmith::AD; use strict; my $ad=esmith::AD->new(); warn "User exists\n" if ($ad->doesUserExist('greg')); Proper code (child method called from child constructor): use esmith::AD::User; use strict; my $ad=esmith::AD::User->new(); warn "User exists\n" if ($ad->doesUserExist('greg'));
In reply to Re^2: Method of child module called by parent
by gzartman
in thread Method of child module called by parent
by gzartman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |