File Coverage

blib/lib/Elive/Entity/InvitedGuest.pm
Criterion Covered Total %
statement 15 30 50.0
branch 0 6 0.0
condition 0 6 0.0
subroutine 5 8 62.5
pod 2 2 100.0
total 22 52 42.3


line stmt bran cond sub pod time code
1             package Elive::Entity::InvitedGuest;
2 4     4   30 use warnings; use strict;
  4     4   12  
  4         153  
  4         24  
  4         8  
  4         127  
3              
4 4     4   27 use Mouse;
  4         6  
  4         28  
5 4     4   1481 use Mouse::Util::TypeConstraints;
  4         10  
  4         29  
6              
7             extends 'Elive::Entity';
8              
9 4     4   391 use Carp;
  4         36  
  4         2260  
10              
11             __PACKAGE__->entity_name('InvitedGuest');
12             __PACKAGE__->collection_name('InvitedGuests');
13              
14             has 'invitedGuestId' => (is => 'rw', isa => 'Int');
15             __PACKAGE__->_alias(id => 'invitedGuestId');
16              
17             has 'loginName' => (is => 'rw', isa => 'Str',
18             documentation => "Guest's login name (usually an email address)");
19              
20             has 'displayName' => (is => 'rw', isa => 'Str',
21             documentation => "Guest's display name");
22              
23             sub BUILDARGS {
24 0     0 1   my $class = shift;
25 0           my $spec = shift;
26              
27 0           my $args;
28              
29 0 0 0       if ($spec && ! ref $spec) {
30 0 0         if ($spec =~ m{^ \s*
31             ([^;]*?) # display name
32             \s*
33             \( ([^;\)]+) \) # (login name)
34             \s*
35             (= (\d) \s*)? # possible '=role' (ignored)
36             $}x) {
37              
38 0           $args = {displayName => $1, loginName => $2};
39             }
40             else {
41 0           die "invited guest '$spec': not in format: ()'";
42             }
43             }
44             else {
45 0           $args = $spec;
46             }
47              
48 0           return $args;
49             }
50              
51             coerce 'Elive::Entity::InvitedGuest' => from 'HashRef|Str'
52             => via {Elive::Entity::InvitedGuest->new($_)};
53              
54             =head1 NAME
55              
56             Elive::Entity::InvitedGuest - Invited Guest entity class
57              
58             =head1 DESCRIPTION
59              
60             This is the structural class for an invited guest. It is associated with
61             meetings via the L entity.
62              
63             =cut
64              
65             =head1 METHODS
66              
67             =cut
68              
69             =head2 stringify
70              
71             Serialize a guest as (): e.g. C.
72              
73             =cut
74              
75             sub stringify {
76 0     0 1   my $self = shift;
77 0   0       my $data = shift || $self;
78              
79 0 0         return $data
80             unless Scalar::Util::refaddr($data);
81              
82 0           return sprintf("%s (%s)", $data->{displayName}, $data->{loginName});
83             }
84              
85             sub _retrieve_all {
86 0     0     my ($class, $vals, %opt) = @_;
87              
88             #
89             # No getXxxx command use listXxxx
90             #
91 0           return $class->SUPER::_retrieve_all($vals,
92             command => 'listInvitedGuests',
93             %opt);
94             }
95              
96             =head1 SEE ALSO
97              
98             =over 4
99              
100             =item Elive::Entity::Session
101             =item Elive::Entity::Meeting
102              
103             =back
104              
105             =cut
106              
107             1;