File Coverage

blib/lib/Net/Lighthouse/User/Membership.pm
Criterion Covered Total %
statement 22 22 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 30 31 96.7


line stmt bran cond sub pod time code
1             package Net::Lighthouse::User::Membership;
2 3     3   5490 use Any::Moose;
  3         34857  
  3         28  
3 3     3   3632 use Params::Validate ':all';
  3         9546  
  3         716  
4 3     3   511 use Net::Lighthouse::Util;
  3         7  
  3         205  
5              
6             # read only attr
7             has [qw/id user_id/] => (
8             isa => 'Int',
9             is => 'ro',
10             );
11              
12             has [qw/account project/] => (
13             isa => 'Str',
14             is => 'ro',
15             );
16              
17 3     3   19 no Any::Moose;
  3         6  
  3         20  
18             __PACKAGE__->meta->make_immutable;
19              
20             sub load_from_xml {
21 2     2 1 4392 my $self = shift;
22 2         64 validate_pos( @_,
23             { type => SCALAR | HASHREF, regex => qr/^\s*
24 2         33 my $ref = $self->_translate_from_xml(shift);
25              
26             # dirty hack: some attrs are read-only, and Mouse doesn't support
27             # writer => '...'
28 2         7 for my $k ( keys %$ref ) {
29 6         32 $self->{$k} = $ref->{$k};
30             }
31 2         12 return $self;
32             }
33              
34             sub _translate_from_xml {
35 2     2   6 my $self = shift;
36 2         19 my $ref = Net::Lighthouse::Util->translate_from_xml(shift);
37              
38             # current $ref contains user entry, which is not shown in the document,
39             # and it's not so useful too, let's delete it for now
40 2 50       15 delete $ref->{user} if exists $ref->{user};
41              
42 2         7 return $ref;
43             }
44              
45             1;
46              
47             __END__