in reply to Re^2: OO, Library Configuration and Class Variables
in thread OO, Library Configuration and Class Variables
Or you can even tell User constructor to check some value in main scope:package Lookup; sub new { # gets some config file }; sub get { warn 'You should implement this method!'; } sub set { warn 'You should implement this method!'; } package Lookup::Remote; use base 'Lookup'; sub get { ... }; sub set { ... }; package main; use User; User->init({ source => 'Lookup::Remote', }); my $user = User->new({ id => 1234, });
You still have to inform the User class what class it will use to get data. I can be wrong, that's the reason I come to perlmonks :)package User; sub new { ... $self->{'source'} = $main::USER_LOOKUP_SOURCE; ... } package main; use User; our $USER_LOOKUP_SOURCE = LookupFactory->new('Remote'); my $user = User->new({ id => 1234, });
Update: I think it is like DBI specs. I don't know what is going under the DBD module, but I have to inform DBI where the data is.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: OO, Library Configuration and Class Variables
by moot (Chaplain) on Jun 23, 2005 at 22:18 UTC | |
by Tanktalus (Canon) on Jun 24, 2005 at 02:14 UTC |