bump copyright date to 2009
[gitmo/Moose.git] / lib / 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 If you've ever found yourself thinking "Moose is great, but I wish it
11 did X differently", then you've gone meta. The meta recipes are all
12 about how to change and extend the way Moose does its thing, by
13 changing how the various meta classes (C<Moose::Meta::Class>,
14 C<Moose::Meta::Attribute>, etc) work.
15
16 The metaclass system is a set of classes that describe classes, roles,
17 attributes, etc. The metaclass API lets you ask questions about a
18 class, like "what attributes does it have?", or "what roles does the
19 class do?"
20
21 The metaclass system also lets you actively make changes to a class,
22 for example by adding new methods.
23
24 The interface with which you normally use Moose (C<has>, C<with>,
25 C<extends>) is just a thin layer of syntactic sugar over the
26 underlying metaclass system.
27
28 By extending and changing how this metaclass system works, you can in
29 effect create a modified object implementation for your classes.
30
31 =head2 Examples
32
33 Let's say that you want to additional properties to
34 attributes. Specifically, we want to add a "label" property to each
35 attribute, so we can write C<<
36 My::Class->meta()->get_attribute('size')->label() >>. The first two
37 recipes show two different ways to do this, one with a full
38 meta-attribute subclass, and the other with an attribute trait.
39
40 You might also want to add additional properties to your
41 metaclass. For example, if you were writing an ORM based on Moose, you
42 could associate a table name with each class via the class's metaclass
43 object, letting you write C<< My::Class->meta()->table_name() >>.
44
45 =head1 SEE ALSO
46
47 Many of the MooseX modules on CPAN implement metaclass extensions. A
48 couple good examples include C<MooseX::Singleton> and
49 C<MooseX::AttributeHelpers>. For a more complex example see
50 C<Fey::ORM>.
51
52 =head1 AUTHOR
53
54 Dave Rolsky E<lt>autarch@urth.org<gt>
55
56 =head1 COPYRIGHT AND LICENSE
57
58 Copyright 2009 by Infinity Interactive, Inc.
59
60 L<http://www.iinteractive.com>
61
62 This library is free software; you can redistribute it and/or modify
63 it under the same terms as Perl itself.
64
65 =cut
66
67