| 1 | package WWW::USF::Directory::Entry::Affiliation; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.008001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | ########################################################################### | ||||||||||||||||||||||||||||
| 8 | # METADATA | ||||||||||||||||||||||||||||
| 9 | 2 | our $AUTHORITY = 'cpan:DOUGDUDE'; | |||||||||||||||||||||||||||
| 10 | 2 | our $VERSION = '0.003001'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | ########################################################################### | ||||||||||||||||||||||||||||
| 13 | # MOOSE | ||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Moose 0.89; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use MooseX::StrictConstructor 0.08; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | ########################################################################### | ||||||||||||||||||||||||||||
| 18 | # MOOSE TYPES | ||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use MooseX::Types::Common::String qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | NonEmptySimpleStr | ||||||||||||||||||||||||||||
| 21 | 2 | ); | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | ########################################################################### | ||||||||||||||||||||||||||||
| 24 | # ALL IMPORTS BEFORE THIS WILL BE ERASED | ||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use namespace::clean 0.04 -except => [qw(meta)]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | ########################################################################### | ||||||||||||||||||||||||||||
| 28 | # OVERLOADED FUNCTIONS | ||||||||||||||||||||||||||||
| 29 | 2 | ▶ | __PACKAGE__->meta->add_package_symbol(q{&()} => sub { }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | __PACKAGE__->meta->add_package_symbol(q{&(""} => sub { shift->stringify }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | ########################################################################### | ||||||||||||||||||||||||||||
| 33 | # ATTRIBUTES | ||||||||||||||||||||||||||||
| 34 | 2 | has 'department' => ( | |||||||||||||||||||||||||||
| 35 | is => 'ro', | ||||||||||||||||||||||||||||
| 36 | isa => NonEmptySimpleStr, | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | documentation => q{The department this role is in}, | ||||||||||||||||||||||||||||
| 39 | clearer => '_clear_department', | ||||||||||||||||||||||||||||
| 40 | predicate => 'has_department', | ||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||
| 42 | 2 | has 'role' => ( | |||||||||||||||||||||||||||
| 43 | is => 'ro', | ||||||||||||||||||||||||||||
| 44 | isa => NonEmptySimpleStr, | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | documentation => q{The role of the person in the department}, | ||||||||||||||||||||||||||||
| 47 | required => 1, | ||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | ########################################################################### | ||||||||||||||||||||||||||||
| 51 | # METHODS | ||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub stringify { | ||||||||||||||||||||||||||
|
Subroutine
stringify: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | # The default stringify method returns role: department or role | ||||||||||||||||||||||||||||
| 54 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # Start the string with the role | ||||||||||||||||||||||||||||
| 57 | 0 | my $string = $self->role; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ($self->has_department) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | # Add on the department | ||||||||||||||||||||||||||||
| 61 | 0 | $string .= ': ' . $self->department; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | return $string; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | ########################################################################### | ||||||||||||||||||||||||||||
| 68 | # CONSTRUCTOR | ||||||||||||||||||||||||||||
| 69 | 3 | ▶ | sub BUILDARGS { | ||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 3 | my ($class, @args) = @_; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 3 | ▶ | if (@args == 1 && ref $args[0] eq q{}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@args == 1 and ref $args[0] eq ""
MC/DC0%0/2
@args == 1 and ref $args[0] eq ""
@args == 1
ref $args[0] eq ""
Truth table33%1/3
A and B
A= @args == 1B= ref $args[0] eq ""
| |||||||||||||||||||||||||||||
| 73 | # It looks like a single string was passed to the constructor, so | ||||||||||||||||||||||||||||
| 74 | # parse the string. | ||||||||||||||||||||||||||||
| 75 | 3 | my ($role, $department) = $args[0] =~ m{\A (.+?) (?: \s+ : \s+ (.+?) )? \z}msx; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # Set the new arguments with the role | ||||||||||||||||||||||||||||
| 78 | 3 | @args = (role => $role); | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 3 | ▶ | if (defined $department) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | # Add the department if defined | ||||||||||||||||||||||||||||
| 82 | 3 | push @args, department => $department; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | # Continue building | ||||||||||||||||||||||||||||
| 87 | 3 | return $class->SUPER::BUILDARGS(@args); | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | ########################################################################### | ||||||||||||||||||||||||||||
| 91 | # MAKE MOOSE OBJECT IMMUTABLE | ||||||||||||||||||||||||||||
| 92 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 2 | 1; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | __END__ | ||||||||||||||||||||||||||||