I am a novice to Moose but fairly familiar with Perl.

I intend to wrap a Moose package around a non-Moose class by delegation, to 
provide further methods by an inherited class (output into Excel and the 
like).

The Manual is excellent, whereas it took me a while to understand how 
delegation is actually applied in Moose. 
(http://search.cpan.org/~flora/Moose-1.05/lib/Moose/Manual/Delegation.pod)

Here you are my understanding of the "simplest from" given in the Manual:

   { package Website;
   use Moose;

   has 'delegtdURI' => (
        is      => 'ro',
        isa     => 'URI',
        handles => [qw( host path )],
   );
   no Moose;
   }

   use URI;
   $website = Website->new( delegtdURI => URI->new( 
'http://search.cpan.org/~flora/Moose-1.05/lib/Moose/Manual/Delegation.pod' ) );
   print $website->host;

It works fine on my platform and if that is according to your taste I would 
suggest to put a complete code example into the tutorial/manual. I do not 
claim any copyright (just in case).

There is one more question: I want to try "the same" with Data::Table.
Here we are a constructor called fromSQL (among new, fromFile, et al.):

{ package MyTable; 
use Moose;

has 'Tabelle' => (
        is        => 'ro',
        isa       => 'Data::Table',
        handles   => [ qw( csv colmap ) ],
  );
no Moose; }

use Data::Table;
$MC = MyTable->new( 'Tabelle' => Data::Table->fromSQL($dbh, 
                qq|   SELECT customer, PartDescription, sum(Net)
                        FROM MClose
                        GROUP BY customer, PartDescription | ) );
print $MC->csv; #is printing a CSV Table


And it just does not work! The "new" method fails.

($dbh (=database handler) etc. is well defined elsewhere - it all works as it 
should without wrapping a Delegation.)
Platform: perl 5.10.0, Activestate, Win32, Moose 1.05
error message:
Can't locate auto/Data/Table/prepare.al in @INC (@INC contains: 
C:/Perl/site/lib C:/Perl/lib .) at ....\cube06.pl line 446

Do you have any clou what is going wrong here?

Thanks
Thomas


Reply via email to