in reply to Re: Method of child module called by parent
in thread Method of child module called by parent
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'));
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Method of child module called by parent
by Athanasius (Archbishop) on Dec 26, 2014 at 09:33 UTC | |
by gzartman (Novice) on Dec 27, 2014 at 01:32 UTC | |
by three18ti (Monk) on Dec 31, 2014 at 21:30 UTC | |
by Athanasius (Archbishop) on Jan 01, 2015 at 04:06 UTC | |
by three18ti (Monk) on Jan 02, 2015 at 16:49 UTC | |
|
Re^3: Method of child module called by parent
by Anonymous Monk on Dec 26, 2014 at 16:43 UTC |