X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI.pm;h=902f58b31ba410708f6766564705864ac49b3b33;hb=d33015393db77e9bc8e0deeb1a39500b3b5a49eb;hp=7cbbdbf67246304c3ad21f615bdc383f7ad879b9;hpb=a7013a87b67301d8b43c7847b84e06be4802d948;p=freeside.git diff --git a/FS/FS/ClientAPI.pm b/FS/FS/ClientAPI.pm index 7cbbdbf67..902f58b31 100644 --- a/FS/FS/ClientAPI.pm +++ b/FS/FS/ClientAPI.pm @@ -1,42 +1,35 @@ package FS::ClientAPI; use strict; -use vars qw(%handler $domain); +use vars qw(%handler $domain $DEBUG); + +$DEBUG = 0; %handler = (); #find modules foreach my $INC ( @INC ) { - foreach my $file ( glob("$INC/FS/ClientAPI/*.pm") ) { + 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"; + warn "using FS::ClientAPI::$mod" if $DEBUG; eval "use FS::ClientAPI::$mod;"; die "error using FS::ClientAPI::$mod: $@" if $@; } } -#(sub for modules) -sub register_handlers { - my $self = shift; - my %new_handlers = @_; - foreach my $key ( keys %new_handlers ) { - warn "WARNING: redefining sub $key" if exists $handler{$key}; - #warn "registering $key"; - $handler{$key} = $new_handlers{$key}; - } -} - #--- sub dispatch { my ( $self, $name ) = ( shift, shift ); - my $sub = $handler{$name} - or die "unknown FS::ClientAPI sub $name (known: ". join(" ", keys %handler ); - #or die "unknown FS::ClientAPI sub $name"; + $name =~ s(/)(::)g; + my $sub = "FS::ClientAPI::$name"; + no strict 'refs'; &{$sub}(@_); }