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