Profile of Moose.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:34 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose.pm
Statements | Executed 327 statements in 4.75ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 3.54ms | 18.3ms | Moose::::BEGIN@28Moose::BEGIN@28
1 | 1 | 1 | 3.48ms | 79.0ms | Moose::::BEGIN@19Moose::BEGIN@19
1 | 1 | 1 | 3.02ms | 16.9ms | Moose::::BEGIN@36Moose::BEGIN@36
1 | 1 | 1 | 2.12ms | 8.96ms | Moose::::BEGIN@29Moose::BEGIN@29
1 | 1 | 1 | 1.95ms | 2.23ms | Moose::::BEGIN@14Moose::BEGIN@14
1 | 1 | 1 | 1.33ms | 2.66ms | Moose::::BEGIN@39Moose::BEGIN@39
1 | 1 | 1 | 1.09ms | 2.92ms | Moose::::BEGIN@40Moose::BEGIN@40
1 | 1 | 1 | 981µs | 15.0ms | Moose::::BEGIN@15Moose::BEGIN@15
1 | 1 | 1 | 868µs | 2.83ms | Moose::::BEGIN@37Moose::BEGIN@37
1 | 1 | 1 | 862µs | 3.76ms | Moose::::BEGIN@34Moose::BEGIN@34
1 | 1 | 1 | 859µs | 1.62ms | Moose::::BEGIN@41Moose::BEGIN@41
1 | 1 | 1 | 823µs | 98.1ms | Moose::::BEGIN@30Moose::BEGIN@30
1 | 1 | 1 | 656µs | 2.11ms | Moose::::BEGIN@38Moose::BEGIN@38
7 | 1 | 1 | 491µs | 23.8ms | Moose::::init_metaMoose::init_meta
1 | 1 | 1 | 445µs | 1.87ms | Moose::::BEGIN@47Moose::BEGIN@47
1 | 1 | 1 | 421µs | 762µs | Moose::::BEGIN@13Moose::BEGIN@13
1 | 1 | 1 | 378µs | 1.62ms | Moose::::BEGIN@42Moose::BEGIN@42
1 | 1 | 1 | 238µs | 1.70ms | Moose::::BEGIN@32Moose::BEGIN@32
1 | 1 | 1 | 211µs | 211µs | Moose::::bootstrapMoose::bootstrap (xsub)
1 | 1 | 1 | 205µs | 2.20ms | Moose::::BEGIN@18Moose::BEGIN@18
12 | 7 | 3 | 201µs | 28.8ms | Moose::::hasMoose::has
6 | 4 | 4 | 57µs | 215ms | Moose::::withMoose::with
4 | 3 | 3 | 51µs | 13.8ms | Moose::::extendsMoose::extends (recurses: max depth 1, inclusive time 797µs)
1 | 1 | 1 | 14µs | 14µs | Moose::::BEGIN@11Moose::BEGIN@11
1 | 1 | 1 | 10µs | 1.54ms | Moose::::BEGIN@44Moose::BEGIN@44
1 | 1 | 1 | 8µs | 8µs | Moose::::BEGIN@2Moose::BEGIN@2
1 | 1 | 1 | 7µs | 7µs | Moose::::BEGIN@31Moose::BEGIN@31
1 | 1 | 1 | 6µs | 6µs | Moose::::BEGIN@21Moose::BEGIN@21
1 | 1 | 1 | 6µs | 21µs | Moose::::BEGIN@9Moose::BEGIN@9
1 | 1 | 1 | 6µs | 9µs | Moose::::BEGIN@8Moose::BEGIN@8
1 | 1 | 1 | 4µs | 4µs | Moose::::BEGIN@45Moose::BEGIN@45
1 | 1 | 1 | 3µs | 3µs | Moose::::BEGIN@23Moose::BEGIN@23
0 | 0 | 0 | 0s | 0s | Moose::::_get_callerMoose::_get_caller
0 | 0 | 0 | 0s | 0s | Moose::::afterMoose::after
0 | 0 | 0 | 0s | 0s | Moose::::aroundMoose::around
0 | 0 | 0 | 0s | 0s | Moose::::augmentMoose::augment
0 | 0 | 0 | 0s | 0s | Moose::::beforeMoose::before
0 | 0 | 0 | 0s | 0s | Moose::::innerMoose::inner
0 | 0 | 0 | 0s | 0s | Moose::::overrideMoose::override
0 | 0 | 0 | 0s | 0s | Moose::::superMoose::super
0 | 0 | 0 | 0s | 0s | Moose::::throw_errorMoose::throw_error

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Moose;
2 |  |  |  |  | # spent 8µs within Moose::BEGIN@2 which was called: # once (8µs+0s) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 4 BEGIN {
3 | 1 | 4µs |  |  | $Moose::AUTHORITY = 'cpan:STEVAN';
4 | 1 | 20µs | 1 | 8µs | } # spent 8µs making 1 call to Moose::BEGIN@2
5 |  |  |  |  | {
6 | 2 | 1µs |  |  | $Moose::VERSION = '2.0602';
7 |  |  |  |  | }
8 | 3 | 16µs | 2 | 12µs | # spent 9µs (6+3) within Moose::BEGIN@8 which was called: # once (6µs+3µs) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 8 use strict; # spent 9µs making 1 call to Moose::BEGIN@8 # spent 3µs making 1 call to strict::import
9 | 3 | 17µs | 2 | 35µs | # spent 21µs (6+15) within Moose::BEGIN@9 which was called: # once (6µs+15µs) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 9 use warnings; # spent 21µs making 1 call to Moose::BEGIN@9 # spent 15µs making 1 call to warnings::import
10 |  |  |  |  |
11 | 3 | 28µs | 1 | 14µs | # spent 14µs within Moose::BEGIN@11 which was called: # once (14µs+0s) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 11 use 5.008; # spent 14µs making 1 call to Moose::BEGIN@11
12 |  |  |  |  |
13 | 3 | 92µs | 2 | 832µs | # spent 762µs (421+341) within Moose::BEGIN@13 which was called: # once (421µs+341µs) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 13 use Scalar::Util 'blessed'; # spent 762µs making 1 call to Moose::BEGIN@13 # spent 70µs making 1 call to Exporter::import
14 | 3 | 79µs | 2 | 2.32ms | # spent 2.23ms (1.95+276µs) within Moose::BEGIN@14 which was called: # once (1.95ms+276µs) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 14 use Carp 'confess'; # spent 2.23ms making 1 call to Moose::BEGIN@14 # spent 95µs making 1 call to Exporter::import
15 | 3 | 112µs | 2 | 15.1ms | # spent 15.0ms (981µs+14.1) within Moose::BEGIN@15 which was called: # once (981µs+14.1ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 15 use Class::Load 'is_class_loaded'; # spent 15.0ms making 1 call to Moose::BEGIN@15 # spent 48µs making 1 call to Exporter::import
16 |  |  |  |  |
17 |  |  |  |  |
18 | 3 | 83µs | 2 | 2.20ms | # spent 2.20ms (205µs+1.99) within Moose::BEGIN@18 which was called: # once (205µs+1.99ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 18 use Moose::Deprecated; # spent 2.20ms making 1 call to Moose::BEGIN@18 # spent 5µs making 1 call to Package::DeprecationManager::__ANON__[Package/DeprecationManager.pm:61]
19 | 3 | 108µs | 2 | 79.0ms | # spent 79.0ms (3.48+75.5) within Moose::BEGIN@19 which was called: # once (3.48ms+75.5ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 19 use Moose::Exporter; # spent 79.0ms making 1 call to Moose::BEGIN@19 # spent 34µs making 1 call to Moose::Exporter::import
20 |  |  |  |  |
21 | 3 | 39µs | 1 | 6µs | # spent 6µs within Moose::BEGIN@21 which was called: # once (6µs+0s) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 21 use Class::MOP; # spent 6µs making 1 call to Moose::BEGIN@21
22 |  |  |  |  |
23 |  |  |  |  | # spent 3µs within Moose::BEGIN@23 which was called: # once (3µs+0s) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 26 BEGIN {
24 | 1 | 4µs |  |  | die "Class::MOP version $Moose::VERSION required--this is version $Class::MOP::VERSION"
25 |  |  |  |  | if $Moose::VERSION && $Class::MOP::VERSION ne $Moose::VERSION;
26 | 1 | 14µs | 1 | 3µs | } # spent 3µs making 1 call to Moose::BEGIN@23
27 |  |  |  |  |
28 | 3 | 147µs | 1 | 18.3ms | # spent 18.3ms (3.54+14.7) within Moose::BEGIN@28 which was called: # once (3.54ms+14.7ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 28 use Moose::Meta::Class; # spent 18.3ms making 1 call to Moose::BEGIN@28
29 | 3 | 177µs | 1 | 8.96ms | # spent 8.96ms (2.12+6.84) within Moose::BEGIN@29 which was called: # once (2.12ms+6.84ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 29 use Moose::Meta::TypeConstraint; # spent 8.96ms making 1 call to Moose::BEGIN@29
30 | 3 | 160µs | 1 | 98.1ms | # spent 98.1ms (823µs+97.3) within Moose::BEGIN@30 which was called: # once (823µs+97.3ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 30 use Moose::Meta::TypeCoercion; # spent 98.1ms making 1 call to Moose::BEGIN@30
31 | 3 | 19µs | 1 | 7µs | # spent 7µs within Moose::BEGIN@31 which was called: # once (7µs+0s) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 31 use Moose::Meta::Attribute; # spent 7µs making 1 call to Moose::BEGIN@31
32 | 3 | 158µs | 1 | 1.70ms | # spent 1.70ms (238µs+1.46) within Moose::BEGIN@32 which was called: # once (238µs+1.46ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 32 use Moose::Meta::Instance; # spent 1.70ms making 1 call to Moose::BEGIN@32
33 |  |  |  |  |
34 | 3 | 138µs | 1 | 3.76ms | # spent 3.76ms (862µs+2.90) within Moose::BEGIN@34 which was called: # once (862µs+2.90ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 34 use Moose::Object; # spent 3.76ms making 1 call to Moose::BEGIN@34
35 |  |  |  |  |
36 | 3 | 148µs | 1 | 16.9ms | # spent 16.9ms (3.02+13.9) within Moose::BEGIN@36 which was called: # once (3.02ms+13.9ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 36 use Moose::Meta::Role; # spent 16.9ms making 1 call to Moose::BEGIN@36
37 | 3 | 208µs | 1 | 2.83ms | # spent 2.83ms (868µs+1.96) within Moose::BEGIN@37 which was called: # once (868µs+1.96ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 37 use Moose::Meta::Role::Composite; # spent 2.83ms making 1 call to Moose::BEGIN@37
38 | 3 | 144µs | 1 | 2.11ms | # spent 2.11ms (656µs+1.45) within Moose::BEGIN@38 which was called: # once (656µs+1.45ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 38 use Moose::Meta::Role::Application; # spent 2.11ms making 1 call to Moose::BEGIN@38
39 | 3 | 148µs | 1 | 2.66ms | # spent 2.66ms (1.33+1.32) within Moose::BEGIN@39 which was called: # once (1.33ms+1.32ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 39 use Moose::Meta::Role::Application::RoleSummation; # spent 2.66ms making 1 call to Moose::BEGIN@39
40 | 3 | 147µs | 1 | 2.92ms | # spent 2.92ms (1.09+1.83) within Moose::BEGIN@40 which was called: # once (1.09ms+1.83ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 40 use Moose::Meta::Role::Application::ToClass; # spent 2.92ms making 1 call to Moose::BEGIN@40
41 | 3 | 132µs | 1 | 1.62ms | # spent 1.62ms (859µs+764µs) within Moose::BEGIN@41 which was called: # once (859µs+764µs) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 41 use Moose::Meta::Role::Application::ToRole; # spent 1.62ms making 1 call to Moose::BEGIN@41
42 | 3 | 114µs | 1 | 1.62ms | # spent 1.62ms (378µs+1.25) within Moose::BEGIN@42 which was called: # once (378µs+1.25ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 42 use Moose::Meta::Role::Application::ToInstance; # spent 1.62ms making 1 call to Moose::BEGIN@42
43 |  |  |  |  |
44 | 3 | 37µs | 2 | 3.08ms | # spent 1.54ms (10µs+1.53) within Moose::BEGIN@44 which was called: # once (10µs+1.53ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 44 use Moose::Util::TypeConstraints; # spent 1.54ms making 1 call to Moose::BEGIN@44 # spent 1.53ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:492]
45 | 3 | 19µs | 1 | 4µs | # spent 4µs within Moose::BEGIN@45 which was called: # once (4µs+0s) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 45 use Moose::Util (); # spent 4µs making 1 call to Moose::BEGIN@45
46 |  |  |  |  |
47 | 3 | 1.25ms | 1 | 1.87ms | # spent 1.87ms (445µs+1.42) within Moose::BEGIN@47 which was called: # once (445µs+1.42ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 47 use Moose::Meta::Attribute::Native; # spent 1.87ms making 1 call to Moose::BEGIN@47
48 |  |  |  |  |
49 |  |  |  |  | sub throw_error {
50 |  |  |  |  | # FIXME This
51 |  |  |  |  | shift;
52 |  |  |  |  | goto \&confess
53 |  |  |  |  | }
54 |  |  |  |  |
55 |  |  |  |  | # spent 13.8ms (51µs+13.8) within Moose::extends which was called 4 times, avg 3.45ms/call: # 2 times (26µs+6.45ms) by Moose::extends at line 382 of Moose/Exporter.pm, avg 3.24ms/call # once (15µs+6.50ms) by Tapper::MCP::Scheduler::Controller::BEGIN@11 at line 18 of lib/Tapper/MCP/Net.pm # once (10µs+807µs) by Module::Runtime::require_module at line 10 of lib/Tapper/MCP.pm sub extends {
56 | 6 | 16µs |  |  | my $meta = shift;
57 |  |  |  |  |
58 |  |  |  |  | Moose->throw_error("Must derive at least one class") unless @_;
59 |  |  |  |  |
60 |  |  |  |  | # this checks the metaclass to make sure
61 |  |  |  |  | # it is correct, sometimes it can get out
62 |  |  |  |  | # of sync when the classes are being built
63 |  |  | 2 | 6.47ms | $meta->superclasses(@_); # spent 7.25ms making 2 calls to Moose::Meta::Class::superclasses, avg 3.62ms/call, recursion: max depth 1, sum of overlapping time 780µs
64 |  |  |  |  | }
65 |  |  |  |  |
66 |  |  |  |  | # spent 215ms (57µs+215) within Moose::with which was called 6 times, avg 35.8ms/call: # 3 times (20µs+107ms) by Moose::with at line 382 of Moose/Exporter.pm, avg 35.8ms/call # once (13µs+56.5ms) by Tapper::MCP::Scheduler::Controller::BEGIN@1 at line 61 of lib/Tapper/MCP/Scheduler/Algorithm.pm # once (15µs+43.5ms) by base::import at line 18 of Tapper/Base.pm # once (9µs+7.44ms) by main::BEGIN@1 at line 28 of lib/Tapper/MCP/Scheduler/Controller.pm sub with {
67 | 3 | 23µs | 3 | 107ms | Moose::Util::apply_all_roles(shift, @_); # spent 107ms making 3 calls to Moose::Util::apply_all_roles, avg 35.8ms/call
68 |  |  |  |  | }
69 |  |  |  |  |
70 |  |  |  |  | # spent 28.8ms (201µs+28.6) within Moose::has which was called 12 times, avg 2.40ms/call: # 6 times (138µs+14.2ms) by Moose::has at line 382 of Moose/Exporter.pm, avg 2.39ms/call # once (11µs+2.91ms) by Tapper::MCP::Scheduler::Controller::BEGIN@1 at line 13 of lib/Tapper/MCP/Scheduler/Algorithm.pm # once (12µs+2.67ms) by main::BEGIN@1 at line 13 of lib/Tapper/MCP/Scheduler/Controller.pm # once (10µs+2.45ms) by main::BEGIN@1 at line 14 of lib/Tapper/MCP/Scheduler/Controller.pm # once (10µs+2.42ms) by main::BEGIN@1 at line 23 of lib/Tapper/MCP/Scheduler/Controller.pm # once (10µs+2.09ms) by main::BEGIN@1 at line 26 of lib/Tapper/MCP/Scheduler/Controller.pm # once (10µs+1.88ms) by main::BEGIN@1 at line 25 of lib/Tapper/MCP/Scheduler/Controller.pm sub has {
71 | 42 | 136µs |  |  | my $meta = shift;
72 |  |  |  |  | my $name = shift;
73 |  |  |  |  |
74 |  |  |  |  | Moose->throw_error('Usage: has \'name\' => ( key => value, ... )')
75 |  |  |  |  | if @_ % 2 == 1;
76 |  |  |  |  |
77 |  |  | 6 | 80µs | my %options = ( definition_context => Moose::Util::_caller_info(), @_ ); # spent 80µs making 6 calls to Moose::Util::_caller_info, avg 13µs/call
78 |  |  |  |  | my $attrs = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ];
79 |  |  | 6 | 14.1ms | $meta->add_attribute( $_, %options ) for @$attrs; # spent 14.1ms making 6 calls to Moose::Meta::Class::add_attribute, avg 2.35ms/call
80 |  |  |  |  | }
81 |  |  |  |  |
82 |  |  |  |  | sub before {
83 |  |  |  |  | Moose::Util::add_method_modifier(shift, 'before', \@_);
84 |  |  |  |  | }
85 |  |  |  |  |
86 |  |  |  |  | sub after {
87 |  |  |  |  | Moose::Util::add_method_modifier(shift, 'after', \@_);
88 |  |  |  |  | }
89 |  |  |  |  |
90 |  |  |  |  | sub around {
91 |  |  |  |  | Moose::Util::add_method_modifier(shift, 'around', \@_);
92 |  |  |  |  | }
93 |  |  |  |  |
94 | 1 | 100ns |  |  | our $SUPER_PACKAGE;
95 | 1 | 100ns |  |  | our $SUPER_BODY;
96 | 1 | 500ns |  |  | our @SUPER_ARGS;
97 |  |  |  |  |
98 |  |  |  |  | sub super {
99 |  |  |  |  | # This check avoids a recursion loop - see
100 |  |  |  |  | # t/bugs/super_recursion.t
101 |  |  |  |  | return if defined $SUPER_PACKAGE && $SUPER_PACKAGE ne caller();
102 |  |  |  |  | return unless $SUPER_BODY; $SUPER_BODY->(@SUPER_ARGS);
103 |  |  |  |  | }
104 |  |  |  |  |
105 |  |  |  |  | sub override {
106 |  |  |  |  | my $meta = shift;
107 |  |  |  |  | my ( $name, $method ) = @_;
108 |  |  |  |  | $meta->add_override_method_modifier( $name => $method );
109 |  |  |  |  | }
110 |  |  |  |  |
111 |  |  |  |  | sub inner {
112 |  |  |  |  | my $pkg = caller();
113 |  |  |  |  | our ( %INNER_BODY, %INNER_ARGS );
114 |  |  |  |  |
115 |  |  |  |  | if ( my $body = $INNER_BODY{$pkg} ) {
116 |  |  |  |  | my @args = @{ $INNER_ARGS{$pkg} };
117 |  |  |  |  | local $INNER_ARGS{$pkg};
118 |  |  |  |  | local $INNER_BODY{$pkg};
119 |  |  |  |  | return $body->(@args);
120 |  |  |  |  | } else {
121 |  |  |  |  | return;
122 |  |  |  |  | }
123 |  |  |  |  | }
124 |  |  |  |  |
125 |  |  |  |  | sub augment {
126 |  |  |  |  | my $meta = shift;
127 |  |  |  |  | my ( $name, $method ) = @_;
128 |  |  |  |  | $meta->add_augment_method_modifier( $name => $method );
129 |  |  |  |  | }
130 |  |  |  |  |
131 | 1 | 10µs | 1 | 943µs | Moose::Exporter->setup_import_methods( # spent 943µs making 1 call to Moose::Exporter::setup_import_methods
132 |  |  |  |  | with_meta => [
133 |  |  |  |  | qw( extends with has before after around override augment )
134 |  |  |  |  | ],
135 |  |  |  |  | as_is => [
136 |  |  |  |  | qw( super inner ),
137 |  |  |  |  | \&Carp::confess,
138 |  |  |  |  | \&Scalar::Util::blessed,
139 |  |  |  |  | ],
140 |  |  |  |  | );
141 |  |  |  |  |
142 |  |  |  |  | # spent 23.8ms (491µs+23.3) within Moose::init_meta which was called 7 times, avg 3.40ms/call: # 7 times (491µs+23.3ms) by Moose::Exporter::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Exporter.pm:492] at line 447 of Moose/Exporter.pm, avg 3.40ms/call sub init_meta {
143 | 140 | 555µs |  |  | shift;
144 |  |  |  |  | my %args = @_;
145 |  |  |  |  |
146 |  |  |  |  | my $class = $args{for_class}
147 |  |  |  |  | or Moose->throw_error("Cannot call init_meta without specifying a for_class");
148 |  |  |  |  | my $base_class = $args{base_class} || 'Moose::Object';
149 |  |  |  |  | my $metaclass = $args{metaclass} || 'Moose::Meta::Class';
150 |  |  |  |  | my $meta_name = exists $args{meta_name} ? $args{meta_name} : 'meta';
151 |  |  |  |  |
152 |  |  | 7 | 44µs | Moose->throw_error("The Metaclass $metaclass must be loaded. (Perhaps you forgot to 'use $metaclass'?)") # spent 44µs making 7 calls to Class::Load::XS::is_class_loaded, avg 6µs/call
153 |  |  |  |  | unless is_class_loaded($metaclass);
154 |  |  |  |  |
155 |  |  | 7 | 17µs | Moose->throw_error("The Metaclass $metaclass must be a subclass of Moose::Meta::Class.") # spent 17µs making 7 calls to UNIVERSAL::isa, avg 2µs/call
156 |  |  |  |  | unless $metaclass->isa('Moose::Meta::Class');
157 |  |  |  |  |
158 |  |  |  |  | # make a subtype for each Moose class
159 |  |  | 14 | 6.55ms | class_type($class) # spent 6.34ms making 7 calls to Moose::Util::TypeConstraints::class_type, avg 906µs/call # spent 213µs making 7 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 30µs/call
160 |  |  |  |  | unless find_type_constraint($class);
161 |  |  |  |  |
162 |  |  |  |  | my $meta;
163 |  |  |  |  |
164 |  |  | 7 | 27µs | if ( $meta = Class::MOP::get_metaclass_by_name($class) ) { # spent 27µs making 7 calls to Class::MOP::get_metaclass_by_name, avg 4µs/call
165 |  |  |  |  | unless ( $meta->isa("Moose::Meta::Class") ) {
166 |  |  |  |  | my $error_message = "$class already has a metaclass, but it does not inherit $metaclass ($meta).";
167 |  |  |  |  | if ( $meta->isa('Moose::Meta::Role') ) {
168 |  |  |  |  | Moose->throw_error($error_message . ' You cannot make the same thing a role and a class. Remove either Moose or Moose::Role.');
169 |  |  |  |  | } else {
170 |  |  |  |  | Moose->throw_error($error_message);
171 |  |  |  |  | }
172 |  |  |  |  | }
173 |  |  |  |  | } else {
174 |  |  |  |  | # no metaclass
175 |  |  |  |  |
176 |  |  |  |  | # now we check whether our ancestors have metaclass, and if so borrow that
177 |  |  | 7 | 65µs | my ( undef, @isa ) = @{ mro::get_linear_isa($class) }; # spent 65µs making 7 calls to mro::get_linear_isa, avg 9µs/call
178 |  |  |  |  |
179 |  |  |  |  | foreach my $ancestor ( @isa ) {
180 |  |  |  |  | my $ancestor_meta = Class::MOP::get_metaclass_by_name($ancestor) || next;
181 |  |  |  |  |
182 |  |  |  |  | my $ancestor_meta_class = $ancestor_meta->_real_ref_name;
183 |  |  |  |  |
184 |  |  |  |  | # if we have an ancestor metaclass that inherits $metaclass, we use
185 |  |  |  |  | # that. This is like _fix_metaclass_incompatibility, but we can do it now.
186 |  |  |  |  |
187 |  |  |  |  | # the case of having an ancestry is not very common, but arises in
188 |  |  |  |  | # e.g. Reaction
189 |  |  |  |  | unless ( $metaclass->isa( $ancestor_meta_class ) ) {
190 |  |  |  |  | if ( $ancestor_meta_class->isa($metaclass) ) {
191 |  |  |  |  | $metaclass = $ancestor_meta_class;
192 |  |  |  |  | }
193 |  |  |  |  | }
194 |  |  |  |  | }
195 |  |  |  |  |
196 |  |  | 7 | 5.97ms | $meta = $metaclass->initialize($class); # spent 5.97ms making 7 calls to Moose::Meta::Class::initialize, avg 853µs/call
197 |  |  |  |  | }
198 |  |  |  |  |
199 |  |  |  |  | if (defined $meta_name) {
200 |  |  |  |  | # also check for inherited non moose 'meta' method?
201 |  |  | 7 | 269µs | my $existing = $meta->get_method($meta_name); # spent 269µs making 7 calls to Class::MOP::Mixin::HasMethods::get_method, avg 38µs/call
202 |  |  |  |  | if ($existing && !$existing->isa('Class::MOP::Method::Meta')) {
203 |  |  |  |  | Carp::cluck "Moose is overwriting an existing method named "
204 |  |  |  |  | . "$meta_name in class $class with a method "
205 |  |  |  |  | . "which returns the class's metaclass. If this is "
206 |  |  |  |  | . "actually what you want, you should remove the "
207 |  |  |  |  | . "existing method, otherwise, you should rename or "
208 |  |  |  |  | . "disable this generated method using the "
209 |  |  |  |  | . "'-meta_name' option to 'use Moose'.";
210 |  |  |  |  | }
211 |  |  | 7 | 4.16ms | $meta->_add_meta_method($meta_name); # spent 4.16ms making 7 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 595µs/call
212 |  |  |  |  | }
213 |  |  |  |  |
214 |  |  |  |  | # make sure they inherit from Moose::Object
215 |  |  | 14 | 5.35ms | $meta->superclasses($base_class) # spent 6.17ms making 14 calls to Moose::Meta::Class::superclasses, avg 441µs/call, recursion: max depth 1, sum of overlapping time 819µs
216 |  |  |  |  | unless $meta->superclasses();
217 |  |  |  |  |
218 |  |  |  |  | return $meta;
219 |  |  |  |  | }
220 |  |  |  |  |
221 |  |  |  |  | # This may be used in some older MooseX extensions.
222 |  |  |  |  | sub _get_caller {
223 |  |  |  |  | goto &Moose::Exporter::_get_caller;
224 |  |  |  |  | }
225 |  |  |  |  |
226 |  |  |  |  | ## make 'em all immutable
227 |  |  |  |  |
228 | 21 | 21µs | 21 | 13µs | $_->make_immutable( # spent 13µs making 21 calls to Class::MOP::Class::is_mutable, avg 638ns/call
229 |  |  |  |  | inline_constructor => 1,
230 |  |  |  |  | constructor_name => "_new",
231 |  |  |  |  | # these are Class::MOP accessors, so they need inlining
232 |  |  |  |  | inline_accessors => 1
233 | 22 | 171µs | 42 | 71.8ms | ) for grep { $_->is_mutable } # spent 69.9ms making 21 calls to Class::MOP::Class::make_immutable, avg 3.33ms/call # spent 1.80ms making 9 calls to Class::MOP::Object::meta, avg 200µs/call # spent 21µs making 2 calls to Moose::Meta::Role::Method::Required::meta, avg 10µs/call # spent 12µs making 1 call to Moose::Meta::TypeCoercion::meta # spent 12µs making 1 call to Moose::Meta::Role::meta # spent 12µs making 1 call to Moose::Meta::TypeCoercion::Union::meta # spent 11µs making 1 call to Moose::Meta::Role::Composite::meta # spent 11µs making 1 call to Moose::Meta::Role::Application::meta # spent 11µs making 1 call to Moose::Meta::Role::Application::ToInstance::meta # spent 11µs making 1 call to Moose::Meta::Role::Application::ToRole::meta # spent 11µs making 1 call to Moose::Meta::Role::Application::RoleSummation::meta # spent 11µs making 1 call to Class::MOP::Mixin::meta # spent 10µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
234 |  |  |  |  | map { $_->meta }
235 |  |  |  |  | qw(
236 |  |  |  |  | Moose::Meta::Attribute
237 |  |  |  |  | Moose::Meta::Class
238 |  |  |  |  | Moose::Meta::Instance
239 |  |  |  |  |
240 |  |  |  |  | Moose::Meta::TypeCoercion
241 |  |  |  |  | Moose::Meta::TypeCoercion::Union
242 |  |  |  |  |
243 |  |  |  |  | Moose::Meta::Method
244 |  |  |  |  | Moose::Meta::Method::Constructor
245 |  |  |  |  | Moose::Meta::Method::Destructor
246 |  |  |  |  | Moose::Meta::Method::Overridden
247 |  |  |  |  | Moose::Meta::Method::Augmented
248 |  |  |  |  |
249 |  |  |  |  | Moose::Meta::Role
250 |  |  |  |  | Moose::Meta::Role::Attribute
251 |  |  |  |  | Moose::Meta::Role::Method
252 |  |  |  |  | Moose::Meta::Role::Method::Required
253 |  |  |  |  | Moose::Meta::Role::Method::Conflicting
254 |  |  |  |  |
255 |  |  |  |  | Moose::Meta::Role::Composite
256 |  |  |  |  |
257 |  |  |  |  | Moose::Meta::Role::Application
258 |  |  |  |  | Moose::Meta::Role::Application::RoleSummation
259 |  |  |  |  | Moose::Meta::Role::Application::ToClass
260 |  |  |  |  | Moose::Meta::Role::Application::ToRole
261 |  |  |  |  | Moose::Meta::Role::Application::ToInstance
262 | 1 | 200ns |  |  | );
263 |  |  |  |  |
264 | 3 | 5µs | 3 | 3µs | $_->make_immutable( # spent 3µs making 3 calls to Class::MOP::Class::is_mutable, avg 967ns/call
265 |  |  |  |  | inline_constructor => 0,
266 |  |  |  |  | constructor_name => undef,
267 |  |  |  |  | # these are Class::MOP accessors, so they need inlining
268 |  |  |  |  | inline_accessors => 1
269 | 4 | 32µs | 6 | 8.12ms | ) for grep { $_->is_mutable } # spent 7.56ms making 3 calls to Class::MOP::Class::make_immutable, avg 2.52ms/call # spent 549µs making 2 calls to Class::MOP::Object::meta, avg 275µs/call # spent 12µs making 1 call to Class::MOP::Mixin::meta
270 |  |  |  |  | map { $_->meta }
271 |  |  |  |  | qw(
272 |  |  |  |  | Moose::Meta::Method::Accessor
273 |  |  |  |  | Moose::Meta::Method::Delegation
274 |  |  |  |  | Moose::Meta::Mixin::AttributeCore
275 | 1 | 200ns |  |  | );
276 |  |  |  |  |
277 | 1 | 24µs |  |  | 1;
278 |  |  |  |  |
279 |  |  |  |  | # ABSTRACT: A postmodern object system for Perl 5
280 |  |  |  |  |
- - |  |  |  |  |
283 |  |  |  |  | =pod
284 |  |  |  |  |
285 |  |  |  |  | =head1 NAME
286 |  |  |  |  |
287 |  |  |  |  | Moose - A postmodern object system for Perl 5
288 |  |  |  |  |
289 |  |  |  |  | =head1 VERSION
290 |  |  |  |  |
291 |  |  |  |  | version 2.0602
292 |  |  |  |  |
293 |  |  |  |  | =head1 SYNOPSIS
294 |  |  |  |  |
295 |  |  |  |  | package Point;
296 |  |  |  |  | use Moose; # automatically turns on strict and warnings
297 |  |  |  |  |
298 |  |  |  |  | has 'x' => (is => 'rw', isa => 'Int');
299 |  |  |  |  | has 'y' => (is => 'rw', isa => 'Int');
300 |  |  |  |  |
301 |  |  |  |  | sub clear {
302 |  |  |  |  | my $self = shift;
303 |  |  |  |  | $self->x(0);
304 |  |  |  |  | $self->y(0);
305 |  |  |  |  | }
306 |  |  |  |  |
307 |  |  |  |  | package Point3D;
308 |  |  |  |  | use Moose;
309 |  |  |  |  |
310 |  |  |  |  | extends 'Point';
311 |  |  |  |  |
312 |  |  |  |  | has 'z' => (is => 'rw', isa => 'Int');
313 |  |  |  |  |
314 |  |  |  |  | after 'clear' => sub {
315 |  |  |  |  | my $self = shift;
316 |  |  |  |  | $self->z(0);
317 |  |  |  |  | };
318 |  |  |  |  |
319 |  |  |  |  | =head1 DESCRIPTION
320 |  |  |  |  |
321 |  |  |  |  | Moose is an extension of the Perl 5 object system.
322 |  |  |  |  |
323 |  |  |  |  | The main goal of Moose is to make Perl 5 Object Oriented programming
324 |  |  |  |  | easier, more consistent, and less tedious. With Moose you can think
325 |  |  |  |  | more about what you want to do and less about the mechanics of OOP.
326 |  |  |  |  |
327 |  |  |  |  | Additionally, Moose is built on top of L<Class::MOP>, which is a
328 |  |  |  |  | metaclass system for Perl 5. This means that Moose not only makes
329 |  |  |  |  | building normal Perl 5 objects better, but it provides the power of
330 |  |  |  |  | metaclass programming as well.
331 |  |  |  |  |
332 |  |  |  |  | =head2 New to Moose?
333 |  |  |  |  |
334 |  |  |  |  | If you're new to Moose, the best place to start is the
335 |  |  |  |  | L<Moose::Manual> docs, followed by the L<Moose::Cookbook>. The intro
336 |  |  |  |  | will show you what Moose is, and how it makes Perl 5 OO better.
337 |  |  |  |  |
338 |  |  |  |  | The cookbook recipes on Moose basics will get you up to speed with
339 |  |  |  |  | many of Moose's features quickly. Once you have an idea of what Moose
340 |  |  |  |  | can do, you can use the API documentation to get more detail on
341 |  |  |  |  | features which interest you.
342 |  |  |  |  |
343 |  |  |  |  | =head2 Moose Extensions
344 |  |  |  |  |
345 |  |  |  |  | The C<MooseX::> namespace is the official place to find Moose extensions.
346 |  |  |  |  | These extensions can be found on the CPAN. The easiest way to find them
347 |  |  |  |  | is to search for them (L<http://search.cpan.org/search?query=MooseX::>),
348 |  |  |  |  | or to examine L<Task::Moose> which aims to keep an up-to-date, easily
349 |  |  |  |  | installable list of Moose extensions.
350 |  |  |  |  |
351 |  |  |  |  | =head1 TRANSLATIONS
352 |  |  |  |  |
353 |  |  |  |  | Much of the Moose documentation has been translated into other languages.
354 |  |  |  |  |
355 |  |  |  |  | =over 4
356 |  |  |  |  |
357 |  |  |  |  | =item Japanese
358 |  |  |  |  |
359 |  |  |  |  | Japanese docs can be found at
360 |  |  |  |  | L<http://perldoc.perlassociation.org/pod/Moose-Doc-JA/index.html>. The
361 |  |  |  |  | source POD files can be found in GitHub:
362 |  |  |  |  | L<http://github.com/jpa/Moose-Doc-JA>
363 |  |  |  |  |
364 |  |  |  |  | =back
365 |  |  |  |  |
366 |  |  |  |  | =head1 BUILDING CLASSES WITH MOOSE
367 |  |  |  |  |
368 |  |  |  |  | Moose makes every attempt to provide as much convenience as possible during
369 |  |  |  |  | class construction/definition, but still stay out of your way if you want it
370 |  |  |  |  | to. Here are a few items to note when building classes with Moose.
371 |  |  |  |  |
372 |  |  |  |  | When you C<use Moose>, Moose will set the class's parent class to
373 |  |  |  |  | L<Moose::Object>, I<unless> the class using Moose already has a parent
374 |  |  |  |  | class. In addition, specifying a parent with C<extends> will change the parent
375 |  |  |  |  | class.
376 |  |  |  |  |
377 |  |  |  |  | Moose will also manage all attributes (including inherited ones) that are
378 |  |  |  |  | defined with C<has>. And (assuming you call C<new>, which is inherited from
379 |  |  |  |  | L<Moose::Object>) this includes properly initializing all instance slots,
380 |  |  |  |  | setting defaults where appropriate, and performing any type constraint checking
381 |  |  |  |  | or coercion.
382 |  |  |  |  |
383 |  |  |  |  | =head1 PROVIDED METHODS
384 |  |  |  |  |
385 |  |  |  |  | Moose provides a number of methods to all your classes, mostly through the
386 |  |  |  |  | inheritance of L<Moose::Object>. There is however, one exception.
387 |  |  |  |  |
388 |  |  |  |  | =over 4
389 |  |  |  |  |
390 |  |  |  |  | =item B<meta>
391 |  |  |  |  |
392 |  |  |  |  | This is a method which provides access to the current class's metaclass.
393 |  |  |  |  |
394 |  |  |  |  | =back
395 |  |  |  |  |
396 |  |  |  |  | =head1 EXPORTED FUNCTIONS
397 |  |  |  |  |
398 |  |  |  |  | Moose will export a number of functions into the class's namespace which
399 |  |  |  |  | may then be used to set up the class. These functions all work directly
400 |  |  |  |  | on the current class.
401 |  |  |  |  |
402 |  |  |  |  | =over 4
403 |  |  |  |  |
404 |  |  |  |  | =item B<extends (@superclasses)>
405 |  |  |  |  |
406 |  |  |  |  | This function will set the superclass(es) for the current class.
407 |  |  |  |  |
408 |  |  |  |  | This approach is recommended instead of C<use base>, because C<use base>
409 |  |  |  |  | actually C<push>es onto the class's C<@ISA>, whereas C<extends> will
410 |  |  |  |  | replace it. This is important to ensure that classes which do not have
411 |  |  |  |  | superclasses still properly inherit from L<Moose::Object>.
412 |  |  |  |  |
413 |  |  |  |  | Each superclass can be followed by a hash reference with options. Currently,
414 |  |  |  |  | only L<-version|Class::MOP/Class Loading Options> is recognized:
415 |  |  |  |  |
416 |  |  |  |  | extends 'My::Parent' => { -version => 0.01 },
417 |  |  |  |  | 'My::OtherParent' => { -version => 0.03 };
418 |  |  |  |  |
419 |  |  |  |  | An exception will be thrown if the version requirements are not
420 |  |  |  |  | satisfied.
421 |  |  |  |  |
422 |  |  |  |  | =item B<with (@roles)>
423 |  |  |  |  |
424 |  |  |  |  | This will apply a given set of C<@roles> to the local class.
425 |  |  |  |  |
426 |  |  |  |  | Like with C<extends>, each specified role can be followed by a hash
427 |  |  |  |  | reference with a L<-version|Class::MOP/Class Loading Options> option:
428 |  |  |  |  |
429 |  |  |  |  | with 'My::Role' => { -version => 0.32 },
430 |  |  |  |  | 'My::Otherrole' => { -version => 0.23 };
431 |  |  |  |  |
432 |  |  |  |  | The specified version requirements must be satisfied, otherwise an
433 |  |  |  |  | exception will be thrown.
434 |  |  |  |  |
435 |  |  |  |  | If your role takes options or arguments, they can be passed along in the
436 |  |  |  |  | hash reference as well.
437 |  |  |  |  |
438 |  |  |  |  | =item B<has $name|@$names =E<gt> %options>
439 |  |  |  |  |
440 |  |  |  |  | This will install an attribute of a given C<$name> into the current class. If
441 |  |  |  |  | the first parameter is an array reference, it will create an attribute for
442 |  |  |  |  | every C<$name> in the list. The C<%options> will be passed to the constructor
443 |  |  |  |  | for L<Moose::Meta::Attribute> (which inherits from L<Class::MOP::Attribute>),
444 |  |  |  |  | so the full documentation for the valid options can be found there. These are
445 |  |  |  |  | the most commonly used options:
446 |  |  |  |  |
447 |  |  |  |  | =over 4
448 |  |  |  |  |
449 |  |  |  |  | =item I<is =E<gt> 'rw'|'ro'>
450 |  |  |  |  |
451 |  |  |  |  | The I<is> option accepts either I<rw> (for read/write) or I<ro> (for read
452 |  |  |  |  | only). These will create either a read/write accessor or a read-only
453 |  |  |  |  | accessor respectively, using the same name as the C<$name> of the attribute.
454 |  |  |  |  |
455 |  |  |  |  | If you need more control over how your accessors are named, you can
456 |  |  |  |  | use the L<reader|Class::MOP::Attribute/reader>,
457 |  |  |  |  | L<writer|Class::MOP::Attribute/writer> and
458 |  |  |  |  | L<accessor|Class::MOP::Attribute/accessor> options inherited from
459 |  |  |  |  | L<Class::MOP::Attribute>, however if you use those, you won't need the
460 |  |  |  |  | I<is> option.
461 |  |  |  |  |
462 |  |  |  |  | =item I<isa =E<gt> $type_name>
463 |  |  |  |  |
464 |  |  |  |  | The I<isa> option uses Moose's type constraint facilities to set up runtime
465 |  |  |  |  | type checking for this attribute. Moose will perform the checks during class
466 |  |  |  |  | construction, and within any accessors. The C<$type_name> argument must be a
467 |  |  |  |  | string. The string may be either a class name or a type defined using
468 |  |  |  |  | Moose's type definition features. (Refer to L<Moose::Util::TypeConstraints>
469 |  |  |  |  | for information on how to define a new type, and how to retrieve type meta-data).
470 |  |  |  |  |
471 |  |  |  |  | =item I<coerce =E<gt> (1|0)>
472 |  |  |  |  |
473 |  |  |  |  | This will attempt to use coercion with the supplied type constraint to change
474 |  |  |  |  | the value passed into any accessors or constructors. You B<must> supply a type
475 |  |  |  |  | constraint, and that type constraint B<must> define a coercion. See
476 |  |  |  |  | L<Moose::Cookbook::Basics::HTTP_SubtypesAndCoercion> for an example.
477 |  |  |  |  |
478 |  |  |  |  | =item I<does =E<gt> $role_name>
479 |  |  |  |  |
480 |  |  |  |  | This will accept the name of a role which the value stored in this attribute
481 |  |  |  |  | is expected to have consumed.
482 |  |  |  |  |
483 |  |  |  |  | =item I<required =E<gt> (1|0)>
484 |  |  |  |  |
485 |  |  |  |  | This marks the attribute as being required. This means a value must be
486 |  |  |  |  | supplied during class construction, I<or> the attribute must be lazy
487 |  |  |  |  | and have either a default or a builder. Note that c<required> does not
488 |  |  |  |  | say anything about the attribute's value, which can be C<undef>.
489 |  |  |  |  |
490 |  |  |  |  | =item I<weak_ref =E<gt> (1|0)>
491 |  |  |  |  |
492 |  |  |  |  | This will tell the class to store the value of this attribute as a weakened
493 |  |  |  |  | reference. If an attribute is a weakened reference, it B<cannot> also be
494 |  |  |  |  | coerced. Note that when a weak ref expires, the attribute's value becomes
495 |  |  |  |  | undefined, and is still considered to be set for purposes of predicate,
496 |  |  |  |  | default, etc.
497 |  |  |  |  |
498 |  |  |  |  | =item I<lazy =E<gt> (1|0)>
499 |  |  |  |  |
500 |  |  |  |  | This will tell the class to not create this slot until absolutely necessary.
501 |  |  |  |  | If an attribute is marked as lazy it B<must> have a default or builder
502 |  |  |  |  | supplied.
503 |  |  |  |  |
504 |  |  |  |  | =item I<trigger =E<gt> $code>
505 |  |  |  |  |
506 |  |  |  |  | The I<trigger> option is a CODE reference which will be called after
507 |  |  |  |  | the value of the attribute is set. The CODE ref is passed the
508 |  |  |  |  | instance itself, the updated value, and the original value if the
509 |  |  |  |  | attribute was already set.
510 |  |  |  |  |
511 |  |  |  |  | You B<can> have a trigger on a read-only attribute.
512 |  |  |  |  |
513 |  |  |  |  | B<NOTE:> Triggers will only fire when you B<assign> to the attribute,
514 |  |  |  |  | either in the constructor, or using the writer. Default and built values will
515 |  |  |  |  | B<not> cause the trigger to be fired.
516 |  |  |  |  |
517 |  |  |  |  | =item I<handles =E<gt> ARRAY | HASH | REGEXP | ROLE | ROLETYPE | DUCKTYPE | CODE>
518 |  |  |  |  |
519 |  |  |  |  | The I<handles> option provides Moose classes with automated delegation features.
520 |  |  |  |  | This is a pretty complex and powerful option. It accepts many different option
521 |  |  |  |  | formats, each with its own benefits and drawbacks.
522 |  |  |  |  |
523 |  |  |  |  | B<NOTE:> The class being delegated to does not need to be a Moose based class,
524 |  |  |  |  | which is why this feature is especially useful when wrapping non-Moose classes.
525 |  |  |  |  |
526 |  |  |  |  | All I<handles> option formats share the following traits:
527 |  |  |  |  |
528 |  |  |  |  | You cannot override a locally defined method with a delegated method; an
529 |  |  |  |  | exception will be thrown if you try. That is to say, if you define C<foo> in
530 |  |  |  |  | your class, you cannot override it with a delegated C<foo>. This is almost never
531 |  |  |  |  | something you would want to do, and if it is, you should do it by hand and not
532 |  |  |  |  | use Moose.
533 |  |  |  |  |
534 |  |  |  |  | You cannot override any of the methods found in Moose::Object, or the C<BUILD>
535 |  |  |  |  | and C<DEMOLISH> methods. These will not throw an exception, but will silently
536 |  |  |  |  | move on to the next method in the list. My reasoning for this is that you would
537 |  |  |  |  | almost never want to do this, since it usually breaks your class. As with
538 |  |  |  |  | overriding locally defined methods, if you do want to do this, you should do it
539 |  |  |  |  | manually, not with Moose.
540 |  |  |  |  |
541 |  |  |  |  | You do not I<need> to have a reader (or accessor) for the attribute in order
542 |  |  |  |  | to delegate to it. Moose will create a means of accessing the value for you,
543 |  |  |  |  | however this will be several times B<less> efficient then if you had given
544 |  |  |  |  | the attribute a reader (or accessor) to use.
545 |  |  |  |  |
546 |  |  |  |  | Below is the documentation for each option format:
547 |  |  |  |  |
548 |  |  |  |  | =over 4
549 |  |  |  |  |
550 |  |  |  |  | =item C<ARRAY>
551 |  |  |  |  |
552 |  |  |  |  | This is the most common usage for I<handles>. You basically pass a list of
553 |  |  |  |  | method names to be delegated, and Moose will install a delegation method
554 |  |  |  |  | for each one.
555 |  |  |  |  |
556 |  |  |  |  | =item C<HASH>
557 |  |  |  |  |
558 |  |  |  |  | This is the second most common usage for I<handles>. Instead of a list of
559 |  |  |  |  | method names, you pass a HASH ref where each key is the method name you
560 |  |  |  |  | want installed locally, and its value is the name of the original method
561 |  |  |  |  | in the class being delegated to.
562 |  |  |  |  |
563 |  |  |  |  | This can be very useful for recursive classes like trees. Here is a
564 |  |  |  |  | quick example (soon to be expanded into a Moose::Cookbook recipe):
565 |  |  |  |  |
566 |  |  |  |  | package Tree;
567 |  |  |  |  | use Moose;
568 |  |  |  |  |
569 |  |  |  |  | has 'node' => (is => 'rw', isa => 'Any');
570 |  |  |  |  |
571 |  |  |  |  | has 'children' => (
572 |  |  |  |  | is => 'ro',
573 |  |  |  |  | isa => 'ArrayRef',
574 |  |  |  |  | default => sub { [] }
575 |  |  |  |  | );
576 |  |  |  |  |
577 |  |  |  |  | has 'parent' => (
578 |  |  |  |  | is => 'rw',
579 |  |  |  |  | isa => 'Tree',
580 |  |  |  |  | weak_ref => 1,
581 |  |  |  |  | handles => {
582 |  |  |  |  | parent_node => 'node',
583 |  |  |  |  | siblings => 'children',
584 |  |  |  |  | }
585 |  |  |  |  | );
586 |  |  |  |  |
587 |  |  |  |  | In this example, the Tree package gets C<parent_node> and C<siblings> methods,
588 |  |  |  |  | which delegate to the C<node> and C<children> methods (respectively) of the Tree
589 |  |  |  |  | instance stored in the C<parent> slot.
590 |  |  |  |  |
591 |  |  |  |  | You may also use an array reference to curry arguments to the original method.
592 |  |  |  |  |
593 |  |  |  |  | has 'thing' => (
594 |  |  |  |  | ...
595 |  |  |  |  | handles => { set_foo => [ set => 'foo' ] },
596 |  |  |  |  | );
597 |  |  |  |  |
598 |  |  |  |  | # $self->set_foo(...) calls $self->thing->set('foo', ...)
599 |  |  |  |  |
600 |  |  |  |  | The first element of the array reference is the original method name, and the
601 |  |  |  |  | rest is a list of curried arguments.
602 |  |  |  |  |
603 |  |  |  |  | =item C<REGEXP>
604 |  |  |  |  |
605 |  |  |  |  | The regexp option works very similar to the ARRAY option, except that it builds
606 |  |  |  |  | the list of methods for you. It starts by collecting all possible methods of the
607 |  |  |  |  | class being delegated to, then filters that list using the regexp supplied here.
608 |  |  |  |  |
609 |  |  |  |  | B<NOTE:> An I<isa> option is required when using the regexp option format. This
610 |  |  |  |  | is so that we can determine (at compile time) the method list from the class.
611 |  |  |  |  | Without an I<isa> this is just not possible.
612 |  |  |  |  |
613 |  |  |  |  | =item C<ROLE> or C<ROLETYPE>
614 |  |  |  |  |
615 |  |  |  |  | With the role option, you specify the name of a role or a
616 |  |  |  |  | L<role type|Moose::Meta::TypeConstraint::Role> whose "interface" then becomes
617 |  |  |  |  | the list of methods to handle. The "interface" can be defined as; the methods
618 |  |  |  |  | of the role and any required methods of the role. It should be noted that this
619 |  |  |  |  | does B<not> include any method modifiers or generated attribute methods (which
620 |  |  |  |  | is consistent with role composition).
621 |  |  |  |  |
622 |  |  |  |  | =item C<DUCKTYPE>
623 |  |  |  |  |
624 |  |  |  |  | With the duck type option, you pass a duck type object whose "interface" then
625 |  |  |  |  | becomes the list of methods to handle. The "interface" can be defined as the
626 |  |  |  |  | list of methods passed to C<duck_type> to create a duck type object. For more
627 |  |  |  |  | information on C<duck_type> please check
628 |  |  |  |  | L<Moose::Util::TypeConstraints>.
629 |  |  |  |  |
630 |  |  |  |  | =item C<CODE>
631 |  |  |  |  |
632 |  |  |  |  | This is the option to use when you really want to do something funky. You should
633 |  |  |  |  | only use it if you really know what you are doing, as it involves manual
634 |  |  |  |  | metaclass twiddling.
635 |  |  |  |  |
636 |  |  |  |  | This takes a code reference, which should expect two arguments. The first is the
637 |  |  |  |  | attribute meta-object this I<handles> is attached to. The second is the
638 |  |  |  |  | metaclass of the class being delegated to. It expects you to return a hash (not
639 |  |  |  |  | a HASH ref) of the methods you want mapped.
640 |  |  |  |  |
641 |  |  |  |  | =back
642 |  |  |  |  |
643 |  |  |  |  | =item I<traits =E<gt> [ @role_names ]>
644 |  |  |  |  |
645 |  |  |  |  | This tells Moose to take the list of C<@role_names> and apply them to the
646 |  |  |  |  | attribute meta-object. Custom attribute metaclass traits are useful for
647 |  |  |  |  | extending the capabilities of the I<has> keyword: they are the simplest way to
648 |  |  |  |  | extend the MOP, but they are still a fairly advanced topic and too much to
649 |  |  |  |  | cover here.
650 |  |  |  |  |
651 |  |  |  |  | See L<Metaclass and Trait Name Resolution> for details on how a trait name is
652 |  |  |  |  | resolved to a role name.
653 |  |  |  |  |
654 |  |  |  |  | Also see L<Moose::Cookbook::Meta::Labeled_AttributeTrait> for a metaclass
655 |  |  |  |  | trait example.
656 |  |  |  |  |
657 |  |  |  |  | =item I<builder> => Str
658 |  |  |  |  |
659 |  |  |  |  | The value of this key is the name of the method that will be called to obtain
660 |  |  |  |  | the value used to initialize the attribute. See the L<builder option docs in
661 |  |  |  |  | Class::MOP::Attribute|Class::MOP::Attribute/builder> and/or
662 |  |  |  |  | L<Moose::Cookbook::Basics::BinaryTree_BuilderAndLazyBuild> for more
663 |  |  |  |  | information.
664 |  |  |  |  |
665 |  |  |  |  | =item I<default> => SCALAR | CODE
666 |  |  |  |  |
667 |  |  |  |  | The value of this key is the default value which will initialize the attribute.
668 |  |  |  |  |
669 |  |  |  |  | NOTE: If the value is a simple scalar (string or number), then it can
670 |  |  |  |  | be just passed as is. However, if you wish to initialize it with a
671 |  |  |  |  | HASH or ARRAY ref, then you need to wrap that inside a CODE reference.
672 |  |  |  |  | See the L<default option docs in
673 |  |  |  |  | Class::MOP::Attribute|Class::MOP::Attribute/default> for more
674 |  |  |  |  | information.
675 |  |  |  |  |
676 |  |  |  |  | =item I<clearer> => Str
677 |  |  |  |  |
678 |  |  |  |  | Creates a method allowing you to clear the value. See the L<clearer option
679 |  |  |  |  | docs in Class::MOP::Attribute|Class::MOP::Attribute/clearer> for more
680 |  |  |  |  | information.
681 |  |  |  |  |
682 |  |  |  |  | =item I<predicate> => Str
683 |  |  |  |  |
684 |  |  |  |  | Creates a method to perform a basic test to see if a value has been set in the
685 |  |  |  |  | attribute. See the L<predicate option docs in
686 |  |  |  |  | Class::MOP::Attribute|Class::MOP::Attribute/predicate> for more information.
687 |  |  |  |  |
688 |  |  |  |  | Note that the predicate will return true even for a C<weak_ref> attribute
689 |  |  |  |  | whose value has expired.
690 |  |  |  |  |
691 |  |  |  |  | =item I<documentation> => $string
692 |  |  |  |  |
693 |  |  |  |  | An arbitrary string that can be retrieved later by calling C<<
694 |  |  |  |  | $attr->documentation >>.
695 |  |  |  |  |
696 |  |  |  |  | =back
697 |  |  |  |  |
698 |  |  |  |  | =item B<has +$name =E<gt> %options>
699 |  |  |  |  |
700 |  |  |  |  | This is variation on the normal attribute creator C<has> which allows you to
701 |  |  |  |  | clone and extend an attribute from a superclass or from a role. Here is an
702 |  |  |  |  | example of the superclass usage:
703 |  |  |  |  |
704 |  |  |  |  | package Foo;
705 |  |  |  |  | use Moose;
706 |  |  |  |  |
707 |  |  |  |  | has 'message' => (
708 |  |  |  |  | is => 'rw',
709 |  |  |  |  | isa => 'Str',
710 |  |  |  |  | default => 'Hello, I am a Foo'
711 |  |  |  |  | );
712 |  |  |  |  |
713 |  |  |  |  | package My::Foo;
714 |  |  |  |  | use Moose;
715 |  |  |  |  |
716 |  |  |  |  | extends 'Foo';
717 |  |  |  |  |
718 |  |  |  |  | has '+message' => (default => 'Hello I am My::Foo');
719 |  |  |  |  |
720 |  |  |  |  | What is happening here is that B<My::Foo> is cloning the C<message> attribute
721 |  |  |  |  | from its parent class B<Foo>, retaining the C<is =E<gt> 'rw'> and C<isa =E<gt>
722 |  |  |  |  | 'Str'> characteristics, but changing the value in C<default>.
723 |  |  |  |  |
724 |  |  |  |  | Here is another example, but within the context of a role:
725 |  |  |  |  |
726 |  |  |  |  | package Foo::Role;
727 |  |  |  |  | use Moose::Role;
728 |  |  |  |  |
729 |  |  |  |  | has 'message' => (
730 |  |  |  |  | is => 'rw',
731 |  |  |  |  | isa => 'Str',
732 |  |  |  |  | default => 'Hello, I am a Foo'
733 |  |  |  |  | );
734 |  |  |  |  |
735 |  |  |  |  | package My::Foo;
736 |  |  |  |  | use Moose;
737 |  |  |  |  |
738 |  |  |  |  | with 'Foo::Role';
739 |  |  |  |  |
740 |  |  |  |  | has '+message' => (default => 'Hello I am My::Foo');
741 |  |  |  |  |
742 |  |  |  |  | In this case, we are basically taking the attribute which the role supplied
743 |  |  |  |  | and altering it within the bounds of this feature.
744 |  |  |  |  |
745 |  |  |  |  | Note that you can only extend an attribute from either a superclass or a role,
746 |  |  |  |  | you cannot extend an attribute in a role that composes over an attribute from
747 |  |  |  |  | another role.
748 |  |  |  |  |
749 |  |  |  |  | Aside from where the attributes come from (one from superclass, the other
750 |  |  |  |  | from a role), this feature works exactly the same. This feature is restricted
751 |  |  |  |  | somewhat, so as to try and force at least I<some> sanity into it. Most options work the same, but there are some exceptions:
752 |  |  |  |  |
753 |  |  |  |  | =over 4
754 |  |  |  |  |
755 |  |  |  |  | =item I<reader>
756 |  |  |  |  |
757 |  |  |  |  | =item I<writer>
758 |  |  |  |  |
759 |  |  |  |  | =item I<accessor>
760 |  |  |  |  |
761 |  |  |  |  | =item I<clearer>
762 |  |  |  |  |
763 |  |  |  |  | =item I<predicate>
764 |  |  |  |  |
765 |  |  |  |  | These options can be added, but cannot override a superclass definition.
766 |  |  |  |  |
767 |  |  |  |  | =item I<traits>
768 |  |  |  |  |
769 |  |  |  |  | You are allowed to B<add> additional traits to the C<traits> definition.
770 |  |  |  |  | These traits will be composed into the attribute, but preexisting traits
771 |  |  |  |  | B<are not> overridden, or removed.
772 |  |  |  |  |
773 |  |  |  |  | =back
774 |  |  |  |  |
775 |  |  |  |  | =item B<before $name|@names|\@names|qr/.../ =E<gt> sub { ... }>
776 |  |  |  |  |
777 |  |  |  |  | =item B<after $name|@names|\@names|qr/.../ =E<gt> sub { ... }>
778 |  |  |  |  |
779 |  |  |  |  | =item B<around $name|@names|\@names|qr/.../ =E<gt> sub { ... }>
780 |  |  |  |  |
781 |  |  |  |  | These three items are syntactic sugar for the before, after, and around method
782 |  |  |  |  | modifier features that L<Class::MOP> provides. More information on these may be
783 |  |  |  |  | found in L<Moose::Manual::MethodModifiers> and the
784 |  |  |  |  | L<Class::MOP::Class documentation|Class::MOP::Class/"Method Modifiers">.
785 |  |  |  |  |
786 |  |  |  |  | =item B<override ($name, &sub)>
787 |  |  |  |  |
788 |  |  |  |  | An C<override> method is a way of explicitly saying "I am overriding this
789 |  |  |  |  | method from my superclass". You can call C<super> within this method, and
790 |  |  |  |  | it will work as expected. The same thing I<can> be accomplished with a normal
791 |  |  |  |  | method call and the C<SUPER::> pseudo-package; it is really your choice.
792 |  |  |  |  |
793 |  |  |  |  | =item B<super>
794 |  |  |  |  |
795 |  |  |  |  | The keyword C<super> is a no-op when called outside of an C<override> method. In
796 |  |  |  |  | the context of an C<override> method, it will call the next most appropriate
797 |  |  |  |  | superclass method with the same arguments as the original method.
798 |  |  |  |  |
799 |  |  |  |  | =item B<augment ($name, &sub)>
800 |  |  |  |  |
801 |  |  |  |  | An C<augment> method, is a way of explicitly saying "I am augmenting this
802 |  |  |  |  | method from my superclass". Once again, the details of how C<inner> and
803 |  |  |  |  | C<augment> work is best described in the
804 |  |  |  |  | L<Moose::Cookbook::Basics::Document_AugmentAndInner>.
805 |  |  |  |  |
806 |  |  |  |  | =item B<inner>
807 |  |  |  |  |
808 |  |  |  |  | The keyword C<inner>, much like C<super>, is a no-op outside of the context of
809 |  |  |  |  | an C<augment> method. You can think of C<inner> as being the inverse of
810 |  |  |  |  | C<super>; the details of how C<inner> and C<augment> work is best described in
811 |  |  |  |  | the L<Moose::Cookbook::Basics::Document_AugmentAndInner>.
812 |  |  |  |  |
813 |  |  |  |  | =item B<blessed>
814 |  |  |  |  |
815 |  |  |  |  | This is the C<Scalar::Util::blessed> function. It is highly recommended that
816 |  |  |  |  | this is used instead of C<ref> anywhere you need to test for an object's class
817 |  |  |  |  | name.
818 |  |  |  |  |
819 |  |  |  |  | =item B<confess>
820 |  |  |  |  |
821 |  |  |  |  | This is the C<Carp::confess> function, and exported here for historical
822 |  |  |  |  | reasons.
823 |  |  |  |  |
824 |  |  |  |  | =back
825 |  |  |  |  |
826 |  |  |  |  | =head1 METACLASS
827 |  |  |  |  |
828 |  |  |  |  | When you use Moose, you can specify traits which will be applied to your
829 |  |  |  |  | metaclass:
830 |  |  |  |  |
831 |  |  |  |  | use Moose -traits => 'My::Trait';
832 |  |  |  |  |
833 |  |  |  |  | This is very similar to the attribute traits feature. When you do
834 |  |  |  |  | this, your class's C<meta> object will have the specified traits
835 |  |  |  |  | applied to it. See L<Metaclass and Trait Name Resolution> for more
836 |  |  |  |  | details.
837 |  |  |  |  |
838 |  |  |  |  | =head2 Metaclass and Trait Name Resolution
839 |  |  |  |  |
840 |  |  |  |  | By default, when given a trait name, Moose simply tries to load a
841 |  |  |  |  | class of the same name. If such a class does not exist, it then looks
842 |  |  |  |  | for for a class matching
843 |  |  |  |  | B<Moose::Meta::$type::Custom::Trait::$trait_name>. The C<$type>
844 |  |  |  |  | variable here will be one of B<Attribute> or B<Class>, depending on
845 |  |  |  |  | what the trait is being applied to.
846 |  |  |  |  |
847 |  |  |  |  | If a class with this long name exists, Moose checks to see if it has
848 |  |  |  |  | the method C<register_implementation>. This method is expected to
849 |  |  |  |  | return the I<real> class name of the trait. If there is no
850 |  |  |  |  | C<register_implementation> method, it will fall back to using
851 |  |  |  |  | B<Moose::Meta::$type::Custom::Trait::$trait> as the trait name.
852 |  |  |  |  |
853 |  |  |  |  | The lookup method for metaclasses is the same, except that it looks
854 |  |  |  |  | for a class matching B<Moose::Meta::$type::Custom::$metaclass_name>.
855 |  |  |  |  |
856 |  |  |  |  | If all this is confusing, take a look at
857 |  |  |  |  | L<Moose::Cookbook::Meta::Labeled_AttributeTrait>, which demonstrates how to
858 |  |  |  |  | create an attribute trait.
859 |  |  |  |  |
860 |  |  |  |  | =head1 UNIMPORTING FUNCTIONS
861 |  |  |  |  |
862 |  |  |  |  | =head2 B<unimport>
863 |  |  |  |  |
864 |  |  |  |  | Moose offers a way to remove the keywords it exports, through the C<unimport>
865 |  |  |  |  | method. You simply have to say C<no Moose> at the bottom of your code for this
866 |  |  |  |  | to work. Here is an example:
867 |  |  |  |  |
868 |  |  |  |  | package Person;
869 |  |  |  |  | use Moose;
870 |  |  |  |  |
871 |  |  |  |  | has 'first_name' => (is => 'rw', isa => 'Str');
872 |  |  |  |  | has 'last_name' => (is => 'rw', isa => 'Str');
873 |  |  |  |  |
874 |  |  |  |  | sub full_name {
875 |  |  |  |  | my $self = shift;
876 |  |  |  |  | $self->first_name . ' ' . $self->last_name
877 |  |  |  |  | }
878 |  |  |  |  |
879 |  |  |  |  | no Moose; # keywords are removed from the Person package
880 |  |  |  |  |
881 |  |  |  |  | =head1 EXTENDING AND EMBEDDING MOOSE
882 |  |  |  |  |
883 |  |  |  |  | To learn more about extending Moose, we recommend checking out the
884 |  |  |  |  | "Extending" recipes in the L<Moose::Cookbook>, starting with
885 |  |  |  |  | L<Moose::Cookbook::Extending::ExtensionOverview>, which provides an overview of
886 |  |  |  |  | all the different ways you might extend Moose. L<Moose::Exporter> and
887 |  |  |  |  | L<Moose::Util::MetaRole> are the modules which provide the majority of the
888 |  |  |  |  | extension functionality, so reading their documentation should also be helpful.
889 |  |  |  |  |
890 |  |  |  |  | =head2 The MooseX:: namespace
891 |  |  |  |  |
892 |  |  |  |  | Generally if you're writing an extension I<for> Moose itself you'll want
893 |  |  |  |  | to put your extension in the C<MooseX::> namespace. This namespace is
894 |  |  |  |  | specifically for extensions that make Moose better or different in some
895 |  |  |  |  | fundamental way. It is traditionally B<not> for a package that just happens
896 |  |  |  |  | to use Moose. This namespace follows from the examples of the C<LWPx::>
897 |  |  |  |  | and C<DBIx::> namespaces that perform the same function for C<LWP> and C<DBI>
898 |  |  |  |  | respectively.
899 |  |  |  |  |
900 |  |  |  |  | =head1 METACLASS COMPATIBILITY AND MOOSE
901 |  |  |  |  |
902 |  |  |  |  | Metaclass compatibility is a thorny subject. You should start by
903 |  |  |  |  | reading the "About Metaclass compatibility" section in the
904 |  |  |  |  | C<Class::MOP> docs.
905 |  |  |  |  |
906 |  |  |  |  | Moose will attempt to resolve a few cases of metaclass incompatibility
907 |  |  |  |  | when you set the superclasses for a class, in addition to the cases that
908 |  |  |  |  | C<Class::MOP> handles.
909 |  |  |  |  |
910 |  |  |  |  | Moose tries to determine if the metaclasses only "differ by roles". This
911 |  |  |  |  | means that the parent and child's metaclass share a common ancestor in
912 |  |  |  |  | their respective hierarchies, and that the subclasses under the common
913 |  |  |  |  | ancestor are only different because of role applications. This case is
914 |  |  |  |  | actually fairly common when you mix and match various C<MooseX::*>
915 |  |  |  |  | modules, many of which apply roles to the metaclass.
916 |  |  |  |  |
917 |  |  |  |  | If the parent and child do differ by roles, Moose replaces the
918 |  |  |  |  | metaclass in the child with a newly created metaclass. This metaclass
919 |  |  |  |  | is a subclass of the parent's metaclass which does all of the roles that
920 |  |  |  |  | the child's metaclass did before being replaced. Effectively, this
921 |  |  |  |  | means the new metaclass does all of the roles done by both the
922 |  |  |  |  | parent's and child's original metaclasses.
923 |  |  |  |  |
924 |  |  |  |  | Ultimately, this is all transparent to you except in the case of an
925 |  |  |  |  | unresolvable conflict.
926 |  |  |  |  |
927 |  |  |  |  | =head1 CAVEATS
928 |  |  |  |  |
929 |  |  |  |  | =over 4
930 |  |  |  |  |
931 |  |  |  |  | =item *
932 |  |  |  |  |
933 |  |  |  |  | It should be noted that C<super> and C<inner> B<cannot> be used in the same
934 |  |  |  |  | method. However, they may be combined within the same class hierarchy; see
935 |  |  |  |  | F<t/basics/override_augment_inner_super.t> for an example.
936 |  |  |  |  |
937 |  |  |  |  | The reason for this is that C<super> is only valid within a method
938 |  |  |  |  | with the C<override> modifier, and C<inner> will never be valid within an
939 |  |  |  |  | C<override> method. In fact, C<augment> will skip over any C<override> methods
940 |  |  |  |  | when searching for its appropriate C<inner>.
941 |  |  |  |  |
942 |  |  |  |  | This might seem like a restriction, but I am of the opinion that keeping these
943 |  |  |  |  | two features separate (yet interoperable) actually makes them easy to use, since
944 |  |  |  |  | their behavior is then easier to predict. Time will tell whether I am right or
945 |  |  |  |  | not (UPDATE: so far so good).
946 |  |  |  |  |
947 |  |  |  |  | =back
948 |  |  |  |  |
949 |  |  |  |  | =head1 GETTING HELP
950 |  |  |  |  |
951 |  |  |  |  | We offer both a mailing list and a very active IRC channel.
952 |  |  |  |  |
953 |  |  |  |  | The mailing list is L<mailto:moose@perl.org>. You must be subscribed to send
954 |  |  |  |  | a message. To subscribe, send an empty message to
955 |  |  |  |  | L<mailto:moose-subscribe@perl.org>
956 |  |  |  |  |
957 |  |  |  |  | You can also visit us at C<#moose> on L<irc://irc.perl.org/#moose>
958 |  |  |  |  | This channel is quite active, and questions at all levels (on Moose-related
959 |  |  |  |  | topics ;) are welcome.
960 |  |  |  |  |
961 |  |  |  |  | =head1 ACKNOWLEDGEMENTS
962 |  |  |  |  |
963 |  |  |  |  | =over 4
964 |  |  |  |  |
965 |  |  |  |  | =item I blame Sam Vilain for introducing me to the insanity that is meta-models.
966 |  |  |  |  |
967 |  |  |  |  | =item I blame Audrey Tang for then encouraging my meta-model habit in #perl6.
968 |  |  |  |  |
969 |  |  |  |  | =item Without Yuval "nothingmuch" Kogman this module would not be possible,
970 |  |  |  |  | and it certainly wouldn't have this name ;P
971 |  |  |  |  |
972 |  |  |  |  | =item The basis of the TypeContraints module was Rob Kinyon's idea
973 |  |  |  |  | originally, I just ran with it.
974 |  |  |  |  |
975 |  |  |  |  | =item Thanks to mst & chansen and the whole #moose posse for all the
976 |  |  |  |  | early ideas/feature-requests/encouragement/bug-finding.
977 |  |  |  |  |
978 |  |  |  |  | =item Thanks to David "Theory" Wheeler for meta-discussions and spelling fixes.
979 |  |  |  |  |
980 |  |  |  |  | =back
981 |  |  |  |  |
982 |  |  |  |  | =head1 SEE ALSO
983 |  |  |  |  |
984 |  |  |  |  | =over 4
985 |  |  |  |  |
986 |  |  |  |  | =item L<http://www.iinteractive.com/moose>
987 |  |  |  |  |
988 |  |  |  |  | This is the official web home of Moose. It contains links to our public git
989 |  |  |  |  | repository, as well as links to a number of talks and articles on Moose and
990 |  |  |  |  | Moose related technologies.
991 |  |  |  |  |
992 |  |  |  |  | =item the L<Moose manual|Moose::Manual>
993 |  |  |  |  |
994 |  |  |  |  | This is an introduction to Moose which covers most of the basics.
995 |  |  |  |  |
996 |  |  |  |  | =item Modern Perl, by chromatic
997 |  |  |  |  |
998 |  |  |  |  | This is an introduction to modern Perl programming, which includes a section on
999 |  |  |  |  | Moose. It is available in print and as a free download from
1000 |  |  |  |  | L<http://onyxneon.com/books/modern_perl/>.
1001 |  |  |  |  |
1002 |  |  |  |  | =item The Moose is flying, a tutorial by Randal Schwartz
1003 |  |  |  |  |
1004 |  |  |  |  | Part 1 - L<http://www.stonehenge.com/merlyn/LinuxMag/col94.html>
1005 |  |  |  |  |
1006 |  |  |  |  | Part 2 - L<http://www.stonehenge.com/merlyn/LinuxMag/col95.html>
1007 |  |  |  |  |
1008 |  |  |  |  | =item Several Moose extension modules in the C<MooseX::> namespace.
1009 |  |  |  |  |
1010 |  |  |  |  | See L<http://search.cpan.org/search?query=MooseX::> for extensions.
1011 |  |  |  |  |
1012 |  |  |  |  | =back
1013 |  |  |  |  |
1014 |  |  |  |  | =head2 Books
1015 |  |  |  |  |
1016 |  |  |  |  | =over 4
1017 |  |  |  |  |
1018 |  |  |  |  | =item The Art of the MetaObject Protocol
1019 |  |  |  |  |
1020 |  |  |  |  | I mention this in the L<Class::MOP> docs too, as this book was critical in
1021 |  |  |  |  | the development of both modules and is highly recommended.
1022 |  |  |  |  |
1023 |  |  |  |  | =back
1024 |  |  |  |  |
1025 |  |  |  |  | =head2 Papers
1026 |  |  |  |  |
1027 |  |  |  |  | =over 4
1028 |  |  |  |  |
1029 |  |  |  |  | =item L<http://www.cs.utah.edu/plt/publications/oopsla04-gff.pdf>
1030 |  |  |  |  |
1031 |  |  |  |  | This paper (suggested by lbr on #moose) was what lead to the implementation
1032 |  |  |  |  | of the C<super>/C<override> and C<inner>/C<augment> features. If you really
1033 |  |  |  |  | want to understand them, I suggest you read this.
1034 |  |  |  |  |
1035 |  |  |  |  | =back
1036 |  |  |  |  |
1037 |  |  |  |  | =head1 BUGS
1038 |  |  |  |  |
1039 |  |  |  |  | All complex software has bugs lurking in it, and this module is no
1040 |  |  |  |  | exception.
1041 |  |  |  |  |
1042 |  |  |  |  | Please report any bugs to C<bug-moose@rt.cpan.org>, or through the web
1043 |  |  |  |  | interface at L<http://rt.cpan.org>.
1044 |  |  |  |  |
1045 |  |  |  |  | You can also discuss feature requests or possible bugs on the Moose mailing
1046 |  |  |  |  | list (moose@perl.org) or on IRC at L<irc://irc.perl.org/#moose>.
1047 |  |  |  |  |
1048 |  |  |  |  | =head1 FEATURE REQUESTS
1049 |  |  |  |  |
1050 |  |  |  |  | We are very strict about what features we add to the Moose core, especially
1051 |  |  |  |  | the user-visible features. Instead we have made sure that the underlying
1052 |  |  |  |  | meta-system of Moose is as extensible as possible so that you can add your
1053 |  |  |  |  | own features easily.
1054 |  |  |  |  |
1055 |  |  |  |  | That said, occasionally there is a feature needed in the meta-system
1056 |  |  |  |  | to support your planned extension, in which case you should either
1057 |  |  |  |  | email the mailing list (moose@perl.org) or join us on IRC at
1058 |  |  |  |  | L<irc://irc.perl.org/#moose> to discuss. The
1059 |  |  |  |  | L<Moose::Manual::Contributing> has more detail about how and when you
1060 |  |  |  |  | can contribute.
1061 |  |  |  |  |
1062 |  |  |  |  | =head1 CABAL
1063 |  |  |  |  |
1064 |  |  |  |  | There are only a few people with the rights to release a new version
1065 |  |  |  |  | of Moose. The Moose Cabal are the people to go to with questions regarding
1066 |  |  |  |  | the wider purview of Moose. They help maintain not just the code
1067 |  |  |  |  | but the community as well.
1068 |  |  |  |  |
1069 |  |  |  |  | Stevan (stevan) Little E<lt>stevan@iinteractive.comE<gt>
1070 |  |  |  |  |
1071 |  |  |  |  | Jesse (doy) Luehrs E<lt>doy at tozt dot netE<gt>
1072 |  |  |  |  |
1073 |  |  |  |  | Yuval (nothingmuch) Kogman
1074 |  |  |  |  |
1075 |  |  |  |  | Shawn (sartak) Moore E<lt>sartak@bestpractical.comE<gt>
1076 |  |  |  |  |
1077 |  |  |  |  | Hans Dieter (confound) Pearcey E<lt>hdp@pobox.comE<gt>
1078 |  |  |  |  |
1079 |  |  |  |  | Chris (perigrin) Prather
1080 |  |  |  |  |
1081 |  |  |  |  | Florian Ragwitz E<lt>rafl@debian.orgE<gt>
1082 |  |  |  |  |
1083 |  |  |  |  | Dave (autarch) Rolsky E<lt>autarch@urth.orgE<gt>
1084 |  |  |  |  |
1085 |  |  |  |  | =head1 CONTRIBUTORS
1086 |  |  |  |  |
1087 |  |  |  |  | Moose is a community project, and as such, involves the work of many, many
1088 |  |  |  |  | members of the community beyond just the members in the cabal. In particular:
1089 |  |  |  |  |
1090 |  |  |  |  | Dave (autarch) Rolsky wrote most of the documentation in L<Moose::Manual>.
1091 |  |  |  |  |
1092 |  |  |  |  | John (jgoulah) Goulah wrote L<Moose::Cookbook::Snack::Keywords>.
1093 |  |  |  |  |
1094 |  |  |  |  | Jess (castaway) Robinson wrote L<Moose::Cookbook::Snack::Types>.
1095 |  |  |  |  |
1096 |  |  |  |  | Aran (bluefeet) Clary Deltac wrote
1097 |  |  |  |  | L<Moose::Cookbook::Basics::Genome_OverloadingSubtypesAndCoercion>.
1098 |  |  |  |  |
1099 |  |  |  |  | Anders (Debolaz) Nor Berle contributed L<Test::Moose> and L<Moose::Util>.
1100 |  |  |  |  |
1101 |  |  |  |  | Also, the code in L<Moose::Meta::Attribute::Native> is based on code from the
1102 |  |  |  |  | L<MooseX::AttributeHelpers> distribution, which had contributions from:
1103 |  |  |  |  |
1104 |  |  |  |  | Chris (perigrin) Prather
1105 |  |  |  |  |
1106 |  |  |  |  | Cory (gphat) Watson
1107 |  |  |  |  |
1108 |  |  |  |  | Evan Carroll
1109 |  |  |  |  |
1110 |  |  |  |  | Florian (rafl) Ragwitz
1111 |  |  |  |  |
1112 |  |  |  |  | Jason May
1113 |  |  |  |  |
1114 |  |  |  |  | Jay Hannah
1115 |  |  |  |  |
1116 |  |  |  |  | Jesse (doy) Luehrs
1117 |  |  |  |  |
1118 |  |  |  |  | Paul (frodwith) Driver
1119 |  |  |  |  |
1120 |  |  |  |  | Robert (rlb3) Boone
1121 |  |  |  |  |
1122 |  |  |  |  | Robert Buels
1123 |  |  |  |  |
1124 |  |  |  |  | Robert (phaylon) Sedlacek
1125 |  |  |  |  |
1126 |  |  |  |  | Shawn (Sartak) Moore
1127 |  |  |  |  |
1128 |  |  |  |  | Stevan Little
1129 |  |  |  |  |
1130 |  |  |  |  | Tom (dec) Lanyon
1131 |  |  |  |  |
1132 |  |  |  |  | Yuval Kogman
1133 |  |  |  |  |
1134 |  |  |  |  | Finally, these people also contributed various tests, bug fixes,
1135 |  |  |  |  | documentation, and features to the Moose codebase:
1136 |  |  |  |  |
1137 |  |  |  |  | Aankhen
1138 |  |  |  |  |
1139 |  |  |  |  | Adam (Alias) Kennedy
1140 |  |  |  |  |
1141 |  |  |  |  | Christian (chansen) Hansen
1142 |  |  |  |  |
1143 |  |  |  |  | Cory (gphat) Watson
1144 |  |  |  |  |
1145 |  |  |  |  | Dylan Hardison (doc fixes)
1146 |  |  |  |  |
1147 |  |  |  |  | Eric (ewilhelm) Wilhelm
1148 |  |  |  |  |
1149 |  |  |  |  | Evan Carroll
1150 |  |  |  |  |
1151 |  |  |  |  | Guillermo (groditi) Roditi
1152 |  |  |  |  |
1153 |  |  |  |  | Jason May
1154 |  |  |  |  |
1155 |  |  |  |  | Jay Hannah
1156 |  |  |  |  |
1157 |  |  |  |  | Jonathan (jrockway) Rockway
1158 |  |  |  |  |
1159 |  |  |  |  | Matt (mst) Trout
1160 |  |  |  |  |
1161 |  |  |  |  | Nathan (kolibrie) Gray
1162 |  |  |  |  |
1163 |  |  |  |  | Paul (frodwith) Driver
1164 |  |  |  |  |
1165 |  |  |  |  | Piotr (dexter) Roszatycki
1166 |  |  |  |  |
1167 |  |  |  |  | Robert Buels
1168 |  |  |  |  |
1169 |  |  |  |  | Robert (phaylon) Sedlacek
1170 |  |  |  |  |
1171 |  |  |  |  | Robert (rlb3) Boone
1172 |  |  |  |  |
1173 |  |  |  |  | Sam (mugwump) Vilain
1174 |  |  |  |  |
1175 |  |  |  |  | Scott (konobi) McWhirter
1176 |  |  |  |  |
1177 |  |  |  |  | Shlomi (rindolf) Fish
1178 |  |  |  |  |
1179 |  |  |  |  | Tom (dec) Lanyon
1180 |  |  |  |  |
1181 |  |  |  |  | Wallace (wreis) Reis
1182 |  |  |  |  |
1183 |  |  |  |  | ... and many other #moose folks
1184 |  |  |  |  |
1185 |  |  |  |  | =head1 AUTHOR
1186 |  |  |  |  |
1187 |  |  |  |  | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
1188 |  |  |  |  |
1189 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
1190 |  |  |  |  |
1191 |  |  |  |  | This software is copyright (c) 2012 by Infinity Interactive, Inc..
1192 |  |  |  |  |
1193 |  |  |  |  | This is free software; you can redistribute it and/or modify it under
1194 |  |  |  |  | the same terms as the Perl 5 programming language system itself.
1195 |  |  |  |  |
1196 |  |  |  |  | =cut
1197 |  |  |  |  |
1198 |  |  |  |  |
1199 |  |  |  |  | __END__
|  |  |  |  | # spent 211µs within Moose::bootstrap which was called: # once (211µs+0s) by DynaLoader::bootstrap at line 223 of DynaLoader.pm sub Moose::bootstrap; # xsub