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