Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Moose / Cookbook / Meta / Recipe1.pod
1
2 =pod
3
4 =head1 NAME
5
6 Moose::Cookbook::Meta::Recipe1 - Welcome to the meta world (Why Go Meta?)
7
8 =head1 SUMMARY
9
10 You might want to read L<Moose::Manual::MOP> if you haven't done so
11 yet.
12
13 If you've ever thought "Moose is great, but I wish it did X
14 differently", then you've gone meta. The meta recipes demonstrate how
15 to change and extend the way Moose works by extending and overriding
16 how the meta classes (L<Moose::Meta::Class>,
17 L<Moose::Meta::Attribute>, etc) work.
18
19 The metaclass API is a set of classes that describe classes, roles,
20 attributes, etc. The metaclass API lets you ask questions about a
21 class, like "what attributes does it have?", or "what roles does the
22 class do?"
23
24 The metaclass system also lets you make changes to a class, for
25 example by adding new methods or attributes.
26
27 The interface presented by L<Moose.pm|Moose> (C<has>, C<with>,
28 C<extends>) is just a thin layer of syntactic sugar over the
29 underlying metaclass system.
30
31 By extending and changing how this metaclass system works, you can
32 create your own Moose variant.
33
34 =head2 Examples
35
36 Let's say that you want to additional properties to
37 attributes. Specifically, we want to add a "label" property to each
38 attribute, so we can write C<<
39 My::Class->meta()->get_attribute('size')->label() >>. The first two
40 recipes show two different ways to do this, one with a full
41 meta-attribute subclass, and the other with an attribute trait.
42
43 You might also want to add additional properties to your
44 metaclass. For example, if you were writing an ORM based on Moose, you
45 could associate a table name with each class via the class's metaclass
46 object, letting you write C<< My::Class->meta()->table_name() >>.
47
48 =head1 SEE ALSO
49
50 Many of the MooseX modules on CPAN implement metaclass extensions. A
51 couple good examples include L<MooseX::Singleton> and
52 L<MooseX::AttributeHelpers>. For a more complex example see
53 L<Fey::ORM> or L<Reaction>.
54
55 =head1 AUTHOR
56
57 Dave Rolsky E<lt>autarch@urth.org<gt>
58
59 =head1 COPYRIGHT AND LICENSE
60
61 Copyright 2009 by Infinity Interactive, Inc.
62
63 L<http://www.iinteractive.com>
64
65 This library is free software; you can redistribute it and/or modify
66 it under the same terms as Perl itself.
67
68 =cut
69
70