File Coverage

blib/lib/Siebel/Srvrmgr/Daemon/ActionFactory.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Siebel::Srvrmgr::Daemon::ActionFactory;
2              
3             =pod
4              
5             =head1 NAME
6              
7             Siebel::Srvrmgr::Daemon::ActionFactory - abstract factory to create Action subclasses
8              
9             =head1 SYNOPSIS
10              
11             my $action = Siebel::Srvrmgr::Daemon::ActionFactory->create(
12             $class,
13             {
14             parser => Siebel::Srvrmgr::ListParser->new(),
15             params => \@params
16             }
17             );
18              
19              
20             =head1 DESCRIPTION
21              
22             This is a abstract factory used to instatiate Action classes. It is used primarily by L<Siebel::Srvrmgr::Daemon> class
23             to define the Action objects to process generated output.
24              
25             =cut
26              
27 6     6   3516 use warnings;
  6         19  
  6         296  
28 6     6   46 use strict;
  6         17  
  6         208  
29 6     6   1028 use MooseX::AbstractFactory 0.004000;
  6         74552  
  6         42  
30             our $VERSION = '0.29'; # VERSION
31              
32             =pod
33              
34             =head1 METHODS
35              
36             =head2 create
37              
38             Expects as parameter the name of the class that needs to be instantiated followed by any required parameters for the class to
39             instantiate a new object. It returns the instantiated object, if possible, otherwise it will raise an exception.
40              
41             If a single string (without double semicolon separators) is given as the class name, ActionFactory will understand that it will
42             have to expand it to a full Action subclass name available from this distribution. For example, if a "LoadPrefences" is given it
43             will be expanded to "Siebel::Srvrmgr::Daemon::Action::LoadPreferences" and try to instantiate such object.
44              
45             If a full class name (with double semicolon separators) is given, the factory will try to instantiate that object and return it. That should
46             make possible to create objects from classes outside the distribution directory.
47              
48             =cut
49              
50             implementation_class_via sub {
51              
52             my $classname = shift;
53              
54             if ( $classname =~ /\:{2}/ ) {
55              
56             return $classname;
57              
58             }
59             else {
60              
61             return 'Siebel::Srvrmgr::Daemon::Action::' . $classname;
62              
63             }
64              
65             };
66              
67             =pod
68              
69             =head1 SEE ALSO
70              
71             =over
72              
73             =item *
74              
75             L<Siebel::Srvrmgr::Daemon::Action>
76              
77             =item *
78              
79             L<MooseX::AbstractFactory>
80              
81             =back
82              
83             =head1 AUTHOR
84              
85             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
86              
87             =head1 COPYRIGHT AND LICENSE
88              
89             This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
90              
91             This file is part of Siebel Monitoring Tools.
92              
93             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
94             it under the terms of the GNU General Public License as published by
95             the Free Software Foundation, either version 3 of the License, or
96             (at your option) any later version.
97              
98             Siebel Monitoring Tools is distributed in the hope that it will be useful,
99             but WITHOUT ANY WARRANTY; without even the implied warranty of
100             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101             GNU General Public License for more details.
102              
103             You should have received a copy of the GNU General Public License
104             along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>.
105              
106             =cut
107              
108             1;