+package Moose::Cookbook::Extending::Recipe4;
-=pod
+# ABSTRACT: Acting like Moose.pm and providing sugar Moose-style
+
+__END__
-=head1 NAME
-Moose::Cookbook::Extending::Recipe4 - Acting like Moose.pm and providing sugar Moose-style
+=pod
=head1 SYNOPSIS
package MyApp::Mooseish;
- use strict;
- use warnings;
-
use Moose ();
use Moose::Exporter;
Moose::Exporter->setup_import_methods(
- with_caller => ['has_table'],
- also => 'Moose',
+ with_meta => ['has_table'],
+ also => 'Moose',
);
sub init_meta {
}
sub has_table {
- my $caller = shift;
- $caller->meta->table(shift);
+ my $meta = shift;
+ $meta->table(shift);
}
package MyApp::Meta::Class;
Moose> with C<use MyApp::Mooseish>. Similarly, C<no Moose> is now
replaced with C<no MyApp::Mooseish>.
-The C<with_caller> parameter specifies a list of functions that should
+The C<with_meta> parameter specifies a list of functions that should
be wrapped before exporting. The wrapper simply ensures that the
importing package name is the first argument to the function, so we
can do C<S<my $caller = shift;>>.
Providing sugar functions can make your extension look much more
Moose-ish. See L<Fey::ORM> for a more extensive example.
-=head1 AUTHOR
-
-Dave Rolsky E<lt>autarch@urth.orgE<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006-2009 by Infinity Interactive, Inc.
-
-L<http://www.iinteractive.com>
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
=begin testing