| 1 | # ============================================================================ | ||||||||||
| 2 | package CatalystX::I18N::Model::Base; | ||||||||||
| 3 | # ============================================================================ | ||||||||||
| 4 | |||||||||||
| 5 | 4 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 4 | extends 'Catalyst::Model'; | |||||||||
| 8 | |||||||||||
| 9 | 4 | has '_app' => ( | |||||||||
| 10 | is => 'rw', | ||||||||||
| 11 | isa => 'Str', | ||||||||||
| 12 | required => 1, | ||||||||||
| 13 | ); | ||||||||||
| 14 | |||||||||||
| 15 | 4 | has 'class' => ( | |||||||||
| 16 | is => 'rw', | ||||||||||
| 17 | isa => 'Str', | ||||||||||
| 18 | lazy_build => 1, | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | 4 | has 'directories' => ( | |||||||||
| 22 | is => 'rw', | ||||||||||
| 23 | isa => 'CatalystX::I18N::Type::DirList', | ||||||||||
| 24 | coerce => 1, | ||||||||||
| 25 | lazy_build => 1, | ||||||||||
| 26 | ); | ||||||||||
| 27 | |||||||||||
| 28 | 6 | ▶ | around BUILDARGS => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 6 | my $orig = shift; | |||||||||
| 30 | 6 | my ( $self,$app,$config ) = @_; | |||||||||
| 31 | |||||||||||
| 32 | # Set _app class | ||||||||||
| 33 | 6 | $config->{_app} = $app; | |||||||||
| 34 | |||||||||||
| 35 | # Call original BUILDARGS | ||||||||||
| 36 | 6 | return $self->$orig($app,$config); | |||||||||
| 37 | 4 | }; | |||||||||
| 38 | |||||||||||
| 39 | 6 | ▶ | sub _build_class { | ||||||||
|
Subroutine
_build_class: called CC=1 SCAR=0.0
| |||||||||||
| 40 | 6 | my ($self) = @_; | |||||||||
| 41 | 6 | return $self->_app.'::'.class_name($self); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 12 | ▶ | sub class_name { | ||||||||
|
Subroutine
class_name: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 45 | 12 | my ($class_name) = @_; | |||||||||
| 46 | 12 | ▶ | $class_name = ref($class_name) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | if ref($class_name); | ||||||||||
| 48 | 12 | my ($return) = reverse split(/::/,$class_name); | |||||||||
| 49 | 12 | return $return; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 6 | ▶ | sub _build_directories { | ||||||||
|
Subroutine
_build_directories: called CC=1 SCAR=0.0
| |||||||||||
| 53 | 6 | my ($self) = @_; | |||||||||
| 54 | |||||||||||
| 55 | 6 | my $class_name = class_name($self->class); | |||||||||
| 56 | 6 | my $calldir = $self->_app; | |||||||||
| 57 | 6 | $calldir =~ s{::}{/}g; | |||||||||
| 58 | |||||||||||
| 59 | 6 | my $file = $calldir.".pm"; | |||||||||
| 60 | 6 | my $path = $INC{$file}; | |||||||||
| 61 | 6 | $path =~ s{\.pm$}{/$class_name}; | |||||||||
| 62 | |||||||||||
| 63 | 6 | return [ Path::Class::Dir->new($path) ]; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 4 | __PACKAGE__->meta->make_immutable( inline_constructor => 0 ); | |||||||||
| 67 | 4 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 68 | 4 | 1; | |||||||||