+package Moose::Cookbook::Extending::Recipe1;
-=pod
+# ABSTRACT: Moose extension overview
+
+__END__
-=head1 NAME
-Moose::Cookbook::Extending::Recipe1 - Moose extension overview
+=pod
=head1 DESCRIPTION
metaclass extension. For example, the L<MooseX::AttributeHelpers>
distribution provides a new attribute metaclass that lets you delegate
behavior to a non-object attribute (a hashref or simple number).
+(MooseX::AttributeHelpers has been deprecated in favour of
+L<Moose::Meta::Attribute::Native>, but can still serve as an example).
A metaclass extension can be packaged as a subclass or a
role/trait. If you can, we recommend using traits instead of
use MooseX::Embiggen::Role::Meta::Method::Constructor;
use MooseX::Embiggen::Role::Object;
- my ($import, $unimport, $init_meta) = Moose::Exporter->build_import_methods(
- also => ['Moose']
- metaclass_roles => ['MooseX::Embiggen::Role::Meta::Class'],
+ my ( $import, $unimport, $init_meta ) = Moose::Exporter->build_import_methods(
+ also => ['Moose'], metaclass_roles =>
+ ['MooseX::Embiggen::Role::Meta::Class'],
attribute_metaclass_roles => ['MooseX::Embiggen::Role::Meta::Attribute'],
- constructor_class_roles =>
+ constructor_class_roles =>
['MooseX::Embiggen::Role::Meta::Method::Constructor'],
- base_class_roles => ['MooseX::Embiggen::Role::Object'],
- install => [qw(import unimport)],
+ base_class_roles => ['MooseX::Embiggen::Role::Object'],
+ install => [qw(import unimport)],
);
sub init_meta {
use Moose::Exporter;
Moose::Exporter->setup_import_methods(
- with_caller => ['embiggen'],
- also => 'Moose',
+ with_meta => ['embiggen'],
+ also => 'Moose',
);
sub embiggen {
- my $caller = shift;
- $caller->meta()->embiggen(@_);
+ my $meta = shift;
+ $meta->embiggen(@_);
}
And then the consumer of your extension can use your C<embiggen> sub:
object roles, please consider doing so. Make sure to read the docs for
L<Moose::Exporter> and L<Moose::Util::MetaRole> as well.
-=head1 AUTHOR
-
-Dave Rolsky E<lt>autarch@urth.orgE<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 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.
-
=cut