| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | use Moose::Role; | 
| 3 | 171 |  |  | 171 |  | 101689 | use Moose::Meta::Class (); | 
|  | 171 |  |  |  |  | 5700 |  | 
|  | 171 |  |  |  |  | 1482 |  | 
| 4 | 171 |  |  | 171 |  | 921157 | use Class::MOP; | 
|  | 171 |  |  |  |  | 454 |  | 
|  | 171 |  |  |  |  | 3964 |  | 
| 5 | 171 |  |  | 171 |  | 994 | use Moose::Util (); | 
|  | 171 |  |  |  |  | 1765 |  | 
|  | 171 |  |  |  |  | 3991 |  | 
| 6 | 171 |  |  | 171 |  | 935 |  | 
|  | 171 |  |  |  |  | 389 |  | 
|  | 171 |  |  |  |  | 28027 |  | 
| 7 |  |  |  |  |  |  | my ($class, $attribute, $warn_on_instance) = @_; | 
| 8 |  |  |  |  |  |  | confess("mk_classdata() is a class method, not an object method") | 
| 9 | 5188 |  |  | 5188 | 1 | 748669 | if blessed $class; | 
| 10 | 5188 | 50 |  |  |  | 13201 |  | 
| 11 |  |  |  |  |  |  | my $slot = '$'.$attribute; | 
| 12 |  |  |  |  |  |  | my $accessor =  sub { | 
| 13 | 5188 |  |  |  |  | 10437 | my $pkg = ref $_[0] || $_[0]; | 
| 14 |  |  |  |  |  |  | my $meta = Moose::Util::find_meta($pkg) | 
| 15 | 341262 |  | 66 | 341262 |  | 1192291 | || Moose::Meta::Class->initialize( $pkg ); | 
|  |  |  |  | 341206 |  |  |  | 
|  |  |  |  | 341206 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341209 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341206 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341209 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 341190 |  |  |  | 
|  |  |  |  | 302947 |  |  |  | 
|  |  |  |  | 53 |  |  |  | 
|  |  |  |  | 53 |  |  |  | 
|  |  |  |  | 53 |  |  |  | 
|  |  |  |  | 53 |  |  |  | 
|  |  |  |  | 53 |  |  |  | 
| 16 | 341262 |  | 66 |  |  | 841662 | if (@_ > 1) { | 
| 17 |  |  |  |  |  |  | $meta->namespace->{$attribute} = \$_[1]; | 
| 18 | 341262 | 100 |  |  |  | 5123179 | return $_[1]; | 
| 19 | 11458 |  |  |  |  | 40743 | } | 
| 20 | 11458 |  |  |  |  | 94502 |  | 
| 21 |  |  |  |  |  |  | # tighter version of | 
| 22 |  |  |  |  |  |  | # if ( $meta->has_package_symbol($slot) ) { | 
| 23 |  |  |  |  |  |  | #   return ${ $meta->get_package_symbol($slot) }; | 
| 24 |  |  |  |  |  |  | # } | 
| 25 |  |  |  |  |  |  | no strict 'refs'; | 
| 26 |  |  |  |  |  |  | my $v = *{"${pkg}::${attribute}"}{SCALAR}; | 
| 27 | 171 |  |  | 171 |  | 1302 | if (defined ${$v}) { | 
|  | 171 |  |  |  |  | 511 |  | 
|  | 171 |  |  |  |  | 57051 |  | 
| 28 | 329804 |  |  |  |  | 477025 | return ${$v}; | 
|  | 329804 |  |  |  |  | 1179754 |  | 
| 29 | 329804 | 100 |  |  |  | 501734 | } else { | 
|  | 329804 |  |  |  |  | 686081 |  | 
| 30 | 238601 |  |  |  |  | 334517 | foreach my $super ( $meta->linearized_isa ) { | 
|  | 238601 |  |  |  |  | 1069330 |  | 
| 31 |  |  |  |  |  |  | # tighter version of same after | 
| 32 | 91203 |  |  |  |  | 298462 | # my $super_meta = Moose::Meta::Class->initialize($super); | 
| 33 |  |  |  |  |  |  | my $v = ${"${super}::"}{$attribute} ? *{"${super}::${attribute}"}{SCALAR} : undef; | 
| 34 |  |  |  |  |  |  | if (defined ${$v}) { | 
| 35 | 267677 | 100 |  |  |  | 1071586 | return ${$v}; | 
|  | 267677 |  |  |  |  | 825387 |  | 
|  | 210514 |  |  |  |  | 524303 |  | 
| 36 | 267677 | 100 |  |  |  | 366467 | } | 
|  | 267677 |  |  |  |  | 576459 |  | 
| 37 | 83828 |  |  |  |  | 125394 | } | 
|  | 83828 |  |  |  |  | 335868 |  | 
| 38 |  |  |  |  |  |  | } | 
| 39 |  |  |  |  |  |  | return; | 
| 40 |  |  |  |  |  |  | }; | 
| 41 | 7375 |  |  |  |  | 39701 |  | 
| 42 | 5188 |  |  |  |  | 28279 | confess("Failed to create accessor: $@ ") | 
| 43 |  |  |  |  |  |  | unless ref $accessor eq 'CODE'; | 
| 44 | 5188 | 50 |  |  |  | 14734 |  | 
| 45 |  |  |  |  |  |  | my $meta = $class->Class::MOP::Object::meta(); | 
| 46 |  |  |  |  |  |  | confess "${class}'s metaclass is not a Class::MOP::Class" | 
| 47 | 5188 |  |  |  |  | 16143 | unless $meta->isa('Class::MOP::Class'); | 
| 48 | 5188 | 50 |  |  |  | 94448 |  | 
| 49 |  |  |  |  |  |  | my $was_immutable = $meta->is_immutable; | 
| 50 |  |  |  |  |  |  | my %immutable_options = $meta->immutable_options; | 
| 51 | 5188 |  |  |  |  | 12901 |  | 
| 52 | 5188 |  |  |  |  | 19785 | $meta->make_mutable if $was_immutable; | 
| 53 |  |  |  |  |  |  |  | 
| 54 | 5188 | 50 |  |  |  | 35822 | my $alias = "_${attribute}_accessor"; | 
| 55 |  |  |  |  |  |  | $meta->add_method($alias, $accessor); | 
| 56 | 5188 |  |  |  |  | 10762 | $meta->add_method($attribute, $accessor); | 
| 57 | 5188 |  |  |  |  | 14332 |  | 
| 58 | 5188 |  |  |  |  | 234665 | $meta->make_immutable(%immutable_options) if $was_immutable; | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 5188 | 50 |  |  |  | 172994 | $class->$attribute($_[2]) if(@_ > 2); | 
| 61 |  |  |  |  |  |  | return $accessor; | 
| 62 | 5188 | 100 |  |  |  | 11102 | } | 
| 63 | 5188 |  |  |  |  | 17752 |  | 
| 64 |  |  |  |  |  |  | 1; | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =head1 NAME | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | Catalyst::ClassData - Class data accessors | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =head1 METHODS | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =head2 mk_classdata $name, $optional_value | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | A moose-safe clone of L<Class::Data::Inheritable> that borrows some ideas from | 
| 77 |  |  |  |  |  |  | L<Class::Accessor::Grouped>; | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =head1 AUTHOR | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | =begin stopwords | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | Guillermo Roditi | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | =end stopwords | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | This library is free software. You can redistribute it and/or modify it under | 
| 90 |  |  |  |  |  |  | the same terms as Perl itself. | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | =cut |