File Coverage

blib/lib/App/Addex/Entry.pm
Criterion Covered Total %
statement 22 22 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod 4 4 100.0
total 36 36 100.0


line stmt bran cond sub pod time code
1 5     5   35 use strict;
  5         9  
  5         141  
2 5     5   25 use warnings;
  5         7  
  5         262  
3             package App::Addex::Entry 0.027;
4             # ABSTRACT: an entry in your address book
5              
6 5         75 use Mixin::ExtraFields::Param -fields => {
7             driver => 'HashGuts',
8             moniker => 'field',
9             id => undef,
10 5     5   2385 };
  5         85370  
11              
12 5     5   18452 use Carp ();
  5         12  
  5         848  
13              
14             #pod =method new
15             #pod
16             #pod my $entry = App::Addex::Entry->new(\%arg);
17             #pod
18             #pod This method returns an Addex Entry object.
19             #pod
20             #pod Valid parameters (sure to change) are:
21             #pod
22             #pod name - a full name (required)
23             #pod nick - a nickname (optional)
24             #pod emails - an arrayref of email addresses (required)
25             #pod
26             #pod =cut
27              
28             sub new {
29 24     24 1 49 my ($class, $arg) = @_;
30              
31             # XXX: do some validation -- rjbs, 2007-04-06
32             my $self = {
33             name => $arg->{name},
34             nick => $arg->{nick},
35             emails => $arg->{emails},
36 24         71 };
37              
38 24         39 bless $self => $class;
39              
40 24 100       58 $self->field(%{ $arg->{fields} }) if $arg->{fields};
  16         111  
41              
42 24         845 return $self;
43             }
44              
45             #pod =method name
46             #pod
47             #pod =method nick
48             #pod
49             #pod These methods return the value of the property they name.
50             #pod
51             #pod =cut
52              
53 86     86 1 169 sub name { $_[0]->{name} }
54 6     6 1 16 sub nick { $_[0]->{nick} }
55              
56             #pod =method emails
57             #pod
58             #pod This method returns the entry's email addresses. In scalar context it returns
59             #pod the number of addresses.
60             #pod
61             #pod =cut
62              
63 21     21 1 54 sub emails { @{ $_[0]->{emails} } }
  21         62  
64              
65             #pod =method field
66             #pod
67             #pod my $value = $entry->field($name);
68             #pod
69             #pod $entry->field($name => $value);
70             #pod
71             #pod This method is generated by L<Mixin::ExtraFields::Param|Mixin::ExtraFields::Param>.
72             #pod
73             #pod =cut
74              
75             1;
76              
77             __END__
78              
79             =pod
80              
81             =encoding UTF-8
82              
83             =head1 NAME
84              
85             App::Addex::Entry - an entry in your address book
86              
87             =head1 VERSION
88              
89             version 0.027
90              
91             =head1 PERL VERSION SUPPORT
92              
93             This module has the same support period as perl itself: it supports the two
94             most recent versions of perl. (That is, if the most recently released version
95             is v5.40, then this module should work on both v5.40 and v5.38.)
96              
97             Although it may work on older versions of perl, no guarantee is made that the
98             minimum required version will not be increased. The version may be increased
99             for any reason, and there is no promise that patches will be accepted to lower
100             the minimum required perl.
101              
102             =head1 METHODS
103              
104             =head2 new
105              
106             my $entry = App::Addex::Entry->new(\%arg);
107              
108             This method returns an Addex Entry object.
109              
110             Valid parameters (sure to change) are:
111              
112             name - a full name (required)
113             nick - a nickname (optional)
114             emails - an arrayref of email addresses (required)
115              
116             =head2 name
117              
118             =head2 nick
119              
120             These methods return the value of the property they name.
121              
122             =head2 emails
123              
124             This method returns the entry's email addresses. In scalar context it returns
125             the number of addresses.
126              
127             =head2 field
128              
129             my $value = $entry->field($name);
130              
131             $entry->field($name => $value);
132              
133             This method is generated by L<Mixin::ExtraFields::Param|Mixin::ExtraFields::Param>.
134              
135             =head1 AUTHOR
136              
137             Ricardo SIGNES <rjbs@semiotic.systems>
138              
139             =head1 COPYRIGHT AND LICENSE
140              
141             This software is copyright (c) 2006 by Ricardo SIGNES.
142              
143             This is free software; you can redistribute it and/or modify it under
144             the same terms as the Perl 5 programming language system itself.
145              
146             =cut