File Coverage

blib/lib/Siebel/Srvrmgr/Daemon/Action/Serializable.pm
Criterion Covered Total %
statement 10 12 83.3
branch 3 6 50.0
condition 2 6 33.3
subroutine 2 2 100.0
pod 1 1 100.0
total 18 27 66.6


line stmt bran cond sub pod time code
1             package Siebel::Srvrmgr::Daemon::Action::Serializable;
2              
3 12     12   17454 use Moose::Role;
  12         18  
  12         84  
4              
5             =pod
6              
7             =head1 NAME
8              
9             Siebel::Srvrmgr::Daemon::Action::Serializable - role for serializable subclasses of Siebel::Srvrmgr::Daemon::Action
10              
11             =head1 DESCRIPTION
12              
13             This class is a role, not a subclass of L<Siebel::Srvrmgr::Daemon::Action>. It is intended to be used by subclasses that
14             needs serialization to the filesystem.
15              
16             =head1 ATTRIBUTES
17              
18             =head2 dump_file
19              
20             This attribute is a string used to indicate in which file the data from L<Siebel::Srvmrgr::ListParser::Output::ListCompDef> should
21             be serialized into the OS filesystem. The string can be a complete path or just the filename.
22              
23             =cut
24              
25             has dump_file => (
26             isa => 'Str',
27             is => 'rw',
28             reader => 'get_dump_file',
29             writer => 'set_dump_file'
30             );
31              
32             =pod
33              
34             =head1 METHODS
35              
36             =head2 get_dump_file
37              
38             Returns the string stored in the attribute C<dump_file>.
39              
40             =head2 set_dump_file
41              
42             Sets the attribute C<dump_file>. Expects a string as parameter.
43              
44             =head2 BUILD
45              
46             Right after object creation this method will process the C<params> attribute and retrieve the first index of the array reference
47             to define the C<dump_file> attribute using the method C<set_dump_file>.
48              
49             If the C<params> attribute is an empty reference, the method wil raise an exception. If the value given is undefined or an empty
50             string, an exception will be raised as well.
51              
52             =cut
53              
54             sub BUILD {
55              
56 46     46 1 64 my $self = shift;
57              
58 46         1511 my $params_ref = $self->get_params();
59              
60 46 50 33     133 unless ( ( defined($params_ref) ) and ( scalar( @{$params_ref} ) >= 1 ) ) {
  46         150  
61              
62 0         0 die
63             'Must have at least one value in the params attribute array reference'
64              
65             }
66              
67 46         81 my $file = $params_ref->[0];
68              
69 46 50 33     431 if ( ( defined($file) ) and ( $file ne '' ) ) {
70              
71 46 50       1566 $self->set_dump_file($file) if ( defined($file) );
72              
73             }
74             else {
75              
76 0           die 'dump_file attribute must be defined';
77              
78             }
79              
80             }
81              
82             =pod
83              
84             =head1 SEE ALSO
85              
86             L<Siebel::Srvrmgr::Daemon::Action>
87              
88             =head1 AUTHOR
89              
90             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.org<Egt>
91              
92             =head1 COPYRIGHT AND LICENSE
93              
94             This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.org<E<gt>
95              
96             This file is part of Siebel Monitoring Tools.
97              
98             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
99             it under the terms of the GNU General Public License as published by
100             the Free Software Foundation, either version 3 of the License, or
101             (at your option) any later version.
102              
103             Siebel Monitoring Tools is distributed in the hope that it will be useful,
104             but WITHOUT ANY WARRANTY; without even the implied warranty of
105             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
106             GNU General Public License for more details.
107              
108             You should have received a copy of the GNU General Public License
109             along with Siebel Monitoring Tools. If not, see <http://www.gnu.org/licenses/>.
110              
111             =cut
112              
113             1;