Opinions: API wrapping, how close to original API should you stay?

Nik Clayton nik at ngo.org.uk
Fri Oct 6 08:15:21 PDT 2006

Robbie Bow wrote:
>> Nik Clayton wrote:
>> [1] As an aside, there's quite a lot of tedious make-work code involved in 
>> doing this.  Before I sit down and write one, is anyone aware of a simple 
>> mechanism to take a hash and a mapping of hash keys to method names, and 
>> generate a simple object from the two?
> How about using Class::Accessor e.g. 

Ah, I wasn't clear enough.  I meant using Object::InsideOut.  Currently 
my subclasses are created something like this:

package main {
   my %hash = func_that_returns_hash();

   # %hash has keys 'Foo', 'Bar', 'Baz'

   my $obj = Class->new(%hash);

package Class {
   use Object::InsideOut;

   my @foo :Field
       :Arg(Mandatory => 1, Name => 'Foo')

   my @bar :Field
       :Arg(Mandatory => 1, Name => 'Bar')

   my @baz :Field
       :Arg(Mandatory => 1, Name => 'Baz')

That works, but it's a bit tedious.  Short of eval'ing everything in to 
existence iterating over a list of field names there doesn't seem to be 
handy O::I shortcut.


More information about the MiltonKeynes-pm mailing list