| Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Method/Augmented.pm |
| Statements | Executed 13 statements in 241µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 9µs | 9µs | Moose::Meta::Method::Augmented::BEGIN@2 |
| 1 | 1 | 1 | 9µs | 25µs | Moose::Meta::Method::Augmented::BEGIN@10 |
| 1 | 1 | 1 | 8µs | 13µs | Moose::Meta::Method::Augmented::BEGIN@9 |
| 1 | 1 | 1 | 7µs | 75µs | Moose::Meta::Method::Augmented::BEGIN@12 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Augmented::__ANON__[:49] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Augmented::new |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Method::Augmented; | ||||
| 2 | # spent 9µs within Moose::Meta::Method::Augmented::BEGIN@2 which was called:
# once (9µs+0s) by Moose::Meta::Class::BEGIN@22 at line 4 | ||||
| 3 | 1 | 4µs | $Moose::Meta::Method::Augmented::AUTHORITY = 'cpan:STEVAN'; | ||
| 4 | 1 | 22µs | 1 | 9µs | } # spent 9µs making 1 call to Moose::Meta::Method::Augmented::BEGIN@2 |
| 5 | { | ||||
| 6 | 2 | 1µs | $Moose::Meta::Method::Augmented::VERSION = '2.0602'; | ||
| 7 | } | ||||
| 8 | |||||
| 9 | 3 | 18µs | 2 | 17µs | # spent 13µs (8+5) within Moose::Meta::Method::Augmented::BEGIN@9 which was called:
# once (8µs+5µs) by Moose::Meta::Class::BEGIN@22 at line 9 # spent 13µs making 1 call to Moose::Meta::Method::Augmented::BEGIN@9
# spent 5µs making 1 call to strict::import |
| 10 | 3 | 20µs | 2 | 42µs | # spent 25µs (9+17) within Moose::Meta::Method::Augmented::BEGIN@10 which was called:
# once (9µs+17µs) by Moose::Meta::Class::BEGIN@22 at line 10 # spent 25µs making 1 call to Moose::Meta::Method::Augmented::BEGIN@10
# spent 17µs making 1 call to warnings::import |
| 11 | |||||
| 12 | 3 | 174µs | 2 | 143µs | # spent 75µs (7+68) within Moose::Meta::Method::Augmented::BEGIN@12 which was called:
# once (7µs+68µs) by Moose::Meta::Class::BEGIN@22 at line 12 # spent 75µs making 1 call to Moose::Meta::Method::Augmented::BEGIN@12
# spent 68µs making 1 call to base::import |
| 13 | |||||
| 14 | sub new { | ||||
| 15 | my ( $class, %args ) = @_; | ||||
| 16 | |||||
| 17 | # the package can be overridden by roles | ||||
| 18 | # it is really more like body's compilation stash | ||||
| 19 | # this is where we need to override the definition of super() so that the | ||||
| 20 | # body of the code can call the right overridden version | ||||
| 21 | my $name = $args{name}; | ||||
| 22 | my $meta = $args{class}; | ||||
| 23 | |||||
| 24 | my $super = $meta->find_next_method_by_name($name); | ||||
| 25 | |||||
| 26 | (defined $super) | ||||
| 27 | || $meta->throw_error("You cannot augment '$name' because it has no super method", data => $name); | ||||
| 28 | |||||
| 29 | my $_super_package = $super->package_name; | ||||
| 30 | # BUT!,... if this is an overridden method .... | ||||
| 31 | if ($super->isa('Moose::Meta::Method::Overridden')) { | ||||
| 32 | # we need to be sure that we actually | ||||
| 33 | # find the next method, which is not | ||||
| 34 | # an 'override' method, the reason is | ||||
| 35 | # that an 'override' method will not | ||||
| 36 | # be the one calling inner() | ||||
| 37 | my $real_super = $meta->_find_next_method_by_name_which_is_not_overridden($name); | ||||
| 38 | $_super_package = $real_super->package_name; | ||||
| 39 | } | ||||
| 40 | |||||
| 41 | my $super_body = $super->body; | ||||
| 42 | |||||
| 43 | my $method = $args{method}; | ||||
| 44 | |||||
| 45 | my $body = sub { | ||||
| 46 | local $Moose::INNER_ARGS{$_super_package} = [ @_ ]; | ||||
| 47 | local $Moose::INNER_BODY{$_super_package} = $method; | ||||
| 48 | $super_body->(@_); | ||||
| 49 | }; | ||||
| 50 | |||||
| 51 | # FIXME store additional attrs | ||||
| 52 | $class->wrap( | ||||
| 53 | $body, | ||||
| 54 | package_name => $meta->name, | ||||
| 55 | name => $name | ||||
| 56 | ); | ||||
| 57 | } | ||||
| 58 | |||||
| 59 | 1 | 2µs | 1; | ||
| 60 | |||||
| 61 | # ABSTRACT: A Moose Method metaclass for augmented methods | ||||
| 62 | |||||
| - - | |||||
| 65 | =pod | ||||
| 66 | |||||
| 67 | =head1 NAME | ||||
| 68 | |||||
| 69 | Moose::Meta::Method::Augmented - A Moose Method metaclass for augmented methods | ||||
| 70 | |||||
| 71 | =head1 VERSION | ||||
| 72 | |||||
| 73 | version 2.0602 | ||||
| 74 | |||||
| 75 | =head1 DESCRIPTION | ||||
| 76 | |||||
| 77 | This class implements method augmentation logic for the L<Moose> | ||||
| 78 | C<augment> keyword. | ||||
| 79 | |||||
| 80 | The augmentation subroutine reference will be invoked explicitly using | ||||
| 81 | the C<inner> keyword from the parent class's method definition. | ||||
| 82 | |||||
| 83 | =head1 INHERITANCE | ||||
| 84 | |||||
| 85 | C<Moose::Meta::Method::Augmented> is a subclass of L<Moose::Meta::Method>. | ||||
| 86 | |||||
| 87 | =head1 METHODS | ||||
| 88 | |||||
| 89 | =over 4 | ||||
| 90 | |||||
| 91 | =item B<< Moose::Meta::Method::Augmented->new(%options) >> | ||||
| 92 | |||||
| 93 | This constructs a new object. It accepts the following options: | ||||
| 94 | |||||
| 95 | =over 8 | ||||
| 96 | |||||
| 97 | =item * class | ||||
| 98 | |||||
| 99 | The metaclass object for the class in which the augmentation is being | ||||
| 100 | declared. This option is required. | ||||
| 101 | |||||
| 102 | =item * name | ||||
| 103 | |||||
| 104 | The name of the method which we are augmenting. This method must exist | ||||
| 105 | in one of the class's superclasses. This option is required. | ||||
| 106 | |||||
| 107 | =item * method | ||||
| 108 | |||||
| 109 | The subroutine reference which implements the augmentation. This | ||||
| 110 | option is required. | ||||
| 111 | |||||
| 112 | =back | ||||
| 113 | |||||
| 114 | =back | ||||
| 115 | |||||
| 116 | =head1 BUGS | ||||
| 117 | |||||
| 118 | See L<Moose/BUGS> for details on reporting bugs. | ||||
| 119 | |||||
| 120 | =head1 AUTHOR | ||||
| 121 | |||||
| 122 | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details. | ||||
| 123 | |||||
| 124 | =head1 COPYRIGHT AND LICENSE | ||||
| 125 | |||||
| 126 | This software is copyright (c) 2012 by Infinity Interactive, Inc.. | ||||
| 127 | |||||
| 128 | This is free software; you can redistribute it and/or modify it under | ||||
| 129 | the same terms as the Perl 5 programming language system itself. | ||||
| 130 | |||||
| 131 | =cut | ||||
| 132 | |||||
| 133 | |||||
| 134 | __END__ |