blob: 4ba03f457fbdc8a6dfd6797eea7b5fd654ffb8b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
package FS::ClientAPI;
use strict;
use base 'Exporter';
use vars qw( @EXPORT_OK %handler $domain $DEBUG $me );
@EXPORT_OK = qw( load_clientapi_modules );
$DEBUG = 0;
$me = '[FS::ClientAPI]';
%handler = ();
=head1 NAME
FS::ClientAPI
=item load_clientapi_modules
=cut
sub load_clientapi_modules {
#find modules
foreach my $INC ( @INC ) {
my $glob = "$INC/FS/ClientAPI/*.pm";
warn "FS::ClientAPI: searching $glob" if $DEBUG;
foreach my $file ( glob($glob) ) {
$file =~ /\/(\w+)\.pm$/ or do {
warn "unrecognized ClientAPI file: $file";
next
};
my $mod = $1;
warn "using FS::ClientAPI::$mod" if $DEBUG;
eval "use FS::ClientAPI::$mod;";
die "error using FS::ClientAPI::$mod: $@" if $@;
}
}
}
=item dispatch [ name ]
=cut
sub dispatch {
my ( $self, $name ) = ( shift, shift );
$name =~ s(/)(::)g;
my $sub = "FS::ClientAPI::$name";
warn "$me dispatch: calling $sub with args @_\n" if $DEBUG;
no strict 'refs';
&{$sub}(@_);
}
1;
|