Hi all,

I'm looking for something like aliased.pm, but with a more specific 
functionality.  Where aliased.pm only renames (and loads) one class, I 
want something which aliases an entire class hierarchy and loads 
modules from it on demand.

  use aliased::factory YAPI => 'Yahoo::Marketing';

  # this does: require Yahoo::Marketing::KeywordResearchService
  # and calls Yahoo::Marketing::KeywordResearchService->new(...)
  my $ybis = YAPI::KeywordResearchService(...);

  my $res = $ybis->getRelatedKeywords(
    relatedKeywordRequest => YAPI::RelatedKeywordRequestType(...)
  );

Both Yahoo::Marketing and Google::Adwords have a very long list of 
objects under their namespace and frequently need various objects to be 
passed into their methods (this is largely due to their SOAP APIs and 
that the Perl code exactly mirrors that.)  It seems like this might 
have useful applications elsewhere.

As for implementation:  import() would install a YAPI::AUTOLOAD(), which 
does the require($thing) and $thing->new(...) bit.  Of course, this 
means that the hierarchy is only one level below the aliased namespace.  
This seems like enough (though I have considered making YAPI::Foo() 
install a YAPI::Foo::AUTOLOAD().)

Thoughts?

Thanks,
Eric
-- 
"Because understanding simplicity is complicated."
--Eric Raymond
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------

Reply via email to