NAME
Class::Forward - A class dispatcher that handles namespaces like paths
VERSION
version 0.01
SYNOPSIS
use CGI;
use Class::Forward;
my $q = clsf '/cgi.new'; # srsly?
DESCRIPTION
Class::Forward is designed to simply return class names or dispatch method calls using shorthand. It uses file-system path specification conventions to match against class namespaces.
EXPORTS
clsf
The exported function clsf is responsible for resolving your shorthand. It begets the follow functionaility:
package App::Store;
use CGI;
use Class::Forward;
clsf; # returns App::Store
clsf './user'; # returns App::Store::User
clsf './user.new', name => 'N30'; # return a new App::Store::User object
clsf './user_profile.new'; # ... App::Store::UserProfile object
clsf '//'; # returns App; (top of the calling class)
clsf '//.new'; # returns a new App object
clsf '//view'; # ... returns App::View
clsf '//view.new'; # ... returns a new App::View object
clsf '//view.new.render'; # ... dispatches methods in succession
clsf 'cgi'; # returns CGI
clsf '/cgi'; # ... also returns CGI
# yada yada
1;
The clsf function takes two arguments, the shorthand to be translated, and an optional list of arguments to be passed to the (optional) method appended to the shorthand.
NOTE: There is only limited support for walk up a path, this is generally a bad idea, writing code that executes other code based on its namespace's relativity to the current class could yield unpredictable results, especially if the calling class is ever relocated.
SEE ALSO
Along my travels I recall visiting a similar module on the CPAN called Namespace::Dispatch which provides somewhat of the same functionality. Additionally, since this module looks like something INGY would upload, you might want to check out his offerings also.
AUTHOR
Al Newkirk <anewkirk@ana.io>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Al Newkirk.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.