File Coverage

blib/lib/Rose/HTML/Object/Localized.pm
Criterion Covered Total %
statement 37 39 94.8
branch 15 18 83.3
condition 6 12 50.0
subroutine 8 8 100.0
pod 0 2 0.0
total 66 79 83.5


line stmt bran cond sub pod time code
1              
2             use strict;
3 43     43   354  
  43         79  
  43         1044  
4             use Carp;
5 43     43   175 use Rose::HTML::Object::Message::Localizer;
  43         71  
  43         2270  
6 43     43   22002  
  43         111  
  43         1245  
7             use base 'Rose::Object';
8 43     43   246  
  43         76  
  43         4811  
9             our $VERSION = '0.600';
10              
11             #our $Debug = 0;
12              
13             use Rose::HTML::Object::MakeMethods::Localization
14             (
15             localized_errors =>
16 43         334 [
17             'errors',
18             ],
19             );
20 43     43   17431  
  43         113  
21             use Rose::Class::MakeMethods::Generic
22             (
23             inheritable_scalar =>
24 43         171 [
25             'default_localizer',
26             'default_locale',
27             ],
28             );
29 43     43   6794  
  43         84  
30             {
31             my($invocant) = shift;
32              
33 230     230 0 4731 # Called as object method
34             if(my $class = ref $invocant)
35             {
36 230 100       502 if(@_)
37             {
38 209 50       386 return $invocant->{'localizer'} = shift;
39             }
40 0         0  
41             return $invocant->{'localizer'} || $class->default_localizer;
42             }
43 209   33     726 else # Called as class method
44             {
45             if(@_)
46             {
47 21 100       51 return $invocant->default_localizer(@_);
48             }
49 2         12  
50             return $invocant->default_localizer
51             }
52 19         71 }
53              
54             {
55             my($invocant) = shift;
56              
57             # Called as an object method
58 94     94 0 613 if(my $class = ref $invocant)
59             {
60             if(@_)
61 94 100       192 {
62             return $invocant->{'locale'} = shift;
63 93 100       208 }
64              
65 15         51 return $invocant->{'locale'} if($invocant->{'locale'});
66              
67             foreach my $parent_name (qw(parent_group parent_field parent_form parent))
68 78 100       255 {
69             if($invocant->can($parent_name) && (my $parent = $invocant->$parent_name()))
70 47         93 {
71             my $locale = $parent->locale;
72 184 100 100     1090 return $locale if(defined $locale);
73             }
74 4         26 }
75 4 50       94  
76             return $invocant->localizer->locale || $invocant->localizer->default_locale;
77             }
78             else # Called as a class method
79 43   33     89 {
80             if(@_)
81             {
82             return $invocant->default_locale(shift);
83 1 50       5 }
84              
85 0         0 return $invocant->localizer->locale || $invocant->default_locale;
86             }
87             }
88 1   33     3  
89             1;