| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Ark::Component; | 
| 2 | 61 |  |  | 61 |  | 27485 | use Mouse; | 
|  | 61 |  |  |  |  | 146 |  | 
|  | 61 |  |  |  |  | 340 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | extends 'Class::Data::Inheritable'; | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | __PACKAGE__->mk_classdata(qw/__component_config/); | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | has app => ( | 
| 9 |  |  |  |  |  |  | is       => 'rw', | 
| 10 |  |  |  |  |  |  | isa      => 'Ark::Core', | 
| 11 |  |  |  |  |  |  | weak_ref => 1, | 
| 12 |  |  |  |  |  |  | handles  => ['log', 'context', 'ensure_class_loaded', 'path_to'], | 
| 13 |  |  |  |  |  |  | ); | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 61 |  |  | 61 |  | 25412 | no Mouse; | 
|  | 61 |  |  |  |  | 126 |  | 
|  | 61 |  |  |  |  | 325 |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | sub config { | 
| 18 | 47 |  |  | 47 | 0 | 1219 | my $class  = shift; | 
| 19 | 47 | 100 |  |  |  | 136 | my $config = @_ > 1 ? {@_} : $_[0]; | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 47 | 100 |  |  |  | 195 | $class->__component_config({}) unless $class->__component_config; | 
| 22 |  |  |  |  |  |  |  | 
| 23 | 47 | 100 |  |  |  | 803 | if ($config) { | 
| 24 | 1 | 50 |  |  |  | 3 | for my $key (keys %{ $config || {} }) { | 
|  | 1 |  |  |  |  | 5 |  | 
| 25 | 2 |  |  |  |  | 13 | $class->__component_config->{ $key } = $config->{$key}; | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 | 47 |  |  |  |  | 114 | $class->__component_config; | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | our $class_config_re = qr/^.*?::(Controller|ActionClass|View|Model|Plugin)::/; | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | sub component_name { | 
| 35 | 23 |  |  | 23 | 0 | 244 | my $class = shift; | 
| 36 | 23 | 50 |  |  |  | 67 | $class = ref $class if ref $class; | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 23 |  |  |  |  | 357 | (my $name = $class) =~ s/$class_config_re/$1::/; | 
| 39 | 23 |  |  |  |  | 187 | $name; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | sub class_config { | 
| 43 | 792 |  |  | 792 | 0 | 1039 | my $self   = shift; | 
| 44 | 792 | 50 |  |  |  | 1517 | my $config = @_ > 1 ? {@_} : $_[0]; | 
| 45 | 792 |  |  |  |  | 1265 | my $class  = caller; | 
| 46 |  |  |  |  |  |  |  | 
| 47 | 792 | 50 |  |  |  | 2011 | return unless $self->app; | 
| 48 |  |  |  |  |  |  |  | 
| 49 | 792 |  |  |  |  | 6982 | (my $name = $class) =~ s/$class_config_re/$1::/; | 
| 50 |  |  |  |  |  |  |  | 
| 51 | 792 |  | 100 |  |  | 2696 | my $classconfig = $self->app->config->{ $name } ||= {}; | 
| 52 | 792 | 50 |  |  |  | 6324 | if ($config) { | 
| 53 | 0 | 0 |  |  |  | 0 | for my $key (keys %{ $config || {} }) { | 
|  | 0 |  |  |  |  | 0 |  | 
| 54 | 0 |  |  |  |  | 0 | $classconfig->{ $key } = $config->{$key}; | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  | } | 
| 57 |  |  |  |  |  |  |  | 
| 58 | 792 |  |  |  |  | 6178 | $classconfig; | 
| 59 |  |  |  |  |  |  | } | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | sub class_stash { | 
| 62 | 0 |  |  | 0 | 0 |  | my $self  = shift; | 
| 63 | 0 |  |  |  |  |  | my $class = caller; | 
| 64 | 0 | 0 |  |  |  |  | return unless $self->app; | 
| 65 |  |  |  |  |  |  |  | 
| 66 | 0 |  | 0 |  |  |  | $self->app->class_stash->{ $class } ||= {}; | 
| 67 |  |  |  |  |  |  | } | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | __PACKAGE__->meta->make_immutable; |