| 1 | package Toolforge::MixNMatch::Struct::User; | ||||||||||
| 2 | |||||||||||
| 3 | 8 | ▶ | use base qw(Exporter); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 8 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 8 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 8 | ▶ | use Error::Pure qw(err); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 8 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 8 | ▶ | use Toolforge::MixNMatch::Object::User; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 8 | Readonly::Array our @EXPORT_OK => qw(obj2struct struct2obj); | |||||||||
| 12 | |||||||||||
| 13 | 8 | our $VERSION = 0.04; | |||||||||
| 14 | |||||||||||
| 15 | 5 | ▶ | sub obj2struct { | ||||||||
|
Subroutine
obj2struct: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 16 | 5 | my $obj = shift; | |||||||||
| 17 | |||||||||||
| 18 | 5 | ▶ | if (! defined $obj) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 1 | err "Object doesn't exist."; | |||||||||
| 20 | } | ||||||||||
| 21 | 4 | ▶ | if (! $obj->isa('Toolforge::MixNMatch::Object::User')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 1 | err "Object isn't 'Toolforge::MixNMatch::Object::User'."; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 3 | my $struct_hr = { | |||||||||
| 26 | 'cnt' => $obj->count, | ||||||||||
| 27 | 'uid' => $obj->uid, | ||||||||||
| 28 | 'username' => $obj->username, | ||||||||||
| 29 | }; | ||||||||||
| 30 | |||||||||||
| 31 | 3 | return $struct_hr; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 3 | ▶ | sub struct2obj { | ||||||||
|
Subroutine
struct2obj: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 35 | 3 | my $struct_hr = shift; | |||||||||
| 36 | |||||||||||
| 37 | my $obj = Toolforge::MixNMatch::Object::User->new( | ||||||||||
| 38 | 'count' => $struct_hr->{'cnt'}, | ||||||||||
| 39 | 'uid' => $struct_hr->{'uid'}, | ||||||||||
| 40 | 3 | 'username' => $struct_hr->{'username'}, | |||||||||
| 41 | ); | ||||||||||
| 42 | |||||||||||
| 43 | 3 | return $obj; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 8 | 1; | |||||||||
| 47 | |||||||||||
| 48 | __END__ | ||||||||||