Rename Meta::Recipe1 to Meta::WhyMeta
[gitmo/Moose.git] / lib / Moose / Cookbook / Meta / WhyMeta.pod
CommitLineData
3f36fdae 1package Moose::Cookbook::Meta::WhyMeta;
17a65b17 2
daa0fd7d 3# ABSTRACT: Welcome to the meta world (Why Go Meta?)
4
5__END__
17a65b17 6
17a65b17 7
daa0fd7d 8=pod
17a65b17 9
10=head1 SUMMARY
11
ad0cb4db 12You might want to read L<Moose::Manual::MOP> if you haven't done so
13yet.
17a65b17 14
ad0cb4db 15If you've ever thought "Moose is great, but I wish it did X
16differently", then you've gone meta. The meta recipes demonstrate how
17to change and extend the way Moose works by extending and overriding
18how the meta classes (L<Moose::Meta::Class>,
19L<Moose::Meta::Attribute>, etc) work.
20
21The metaclass API is a set of classes that describe classes, roles,
17a65b17 22attributes, etc. The metaclass API lets you ask questions about a
23class, like "what attributes does it have?", or "what roles does the
24class do?"
25
ad0cb4db 26The metaclass system also lets you make changes to a class, for
27example by adding new methods or attributes.
17a65b17 28
ad0cb4db 29The interface presented by L<Moose.pm|Moose> (C<has>, C<with>,
17a65b17 30C<extends>) is just a thin layer of syntactic sugar over the
31underlying metaclass system.
32
ad0cb4db 33By extending and changing how this metaclass system works, you can
34create your own Moose variant.
17a65b17 35
36=head2 Examples
37
2a67e654 38Let's say that you want to add additional properties to
17a65b17 39attributes. Specifically, we want to add a "label" property to each
40attribute, so we can write C<<
fe66eda1 41My::Class->meta()->get_attribute('size')->label() >>. The first
42recipe shows how to do this using an attribute trait.
17a65b17 43
44You might also want to add additional properties to your
45metaclass. For example, if you were writing an ORM based on Moose, you
46could associate a table name with each class via the class's metaclass
47object, letting you write C<< My::Class->meta()->table_name() >>.
48
49=head1 SEE ALSO
50
51Many of the MooseX modules on CPAN implement metaclass extensions. A
d50f0281 52couple good examples include L<MooseX::Aliases> and
53L<MooseX::UndefTolerant>. For a more complex example see
54L<Fey::ORM> or L<Bread::Board::Declare>.
17a65b17 55
17a65b17 56=cut
57
58