package MooseX::Recipe; use warnings; use strict; use MooseX::Recipe::Builder; my %anon_classes = (); sub import { my ($self,$opts) = @_; my ($calling_class) = caller(); my @roles = @{ $opts->{roles} }; my $reference_string = $opts->{class} . q{|} . join('+', sort @roles); #my $anon_class = $anon_classes{$reference_string} ||= do { my $builder = MooseX::Recipe::Builder->new($opts); my $anon_class = $anon_classes{$calling_class} = $builder->anon_meta; #}; { no strict 'refs'; my $sub_name = "${calling_class}::$opts->{class}"; my $anon_class_name = $anon_class->name(); *{$sub_name} = sub { return $anon_class_name; }; } } =head1 NAME MooseX::Recipe - Cook Moose classes with roles =head1 VERSION Version 0.01 =cut our $VERSION = '0.01'; =head1 SYNOPSIS This module allow you to cook Moose classes with roles for use by individual packages. use MooseX::Recipe { class => q{Pie}, roles => [qw(Apple Blackberry)]; my $apple_and_blackberry_pie = Pie->new(); =head1 DESCRIPTION =head2 Import options =over =item class This is the name of the Moose class you want to cook. This option is required. =item roles Supply an ArrayRef of role names which you want to cook the Moose class with. This option is required. =back =head1 AUTHOR Scott McWhirter, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc MooseX::Recipe You can also look for information at: =over 4 =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * RT: CPAN's request tracker L =item * Search CPAN L =back =head1 ACKNOWLEDGEMENTS Matt Trout, Stevan Little and the maniacs in irc.perl.org #moose =head1 COPYRIGHT & LICENSE Copyright 2007 Scott McWhirter, all rights reserved. This program is released under the following license: BSD =cut 1; # End of MooseX::Recipe