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