Rechercher une page de manuel
Sprog::ClassFactory.3pm
Langue: en
Version: 2005-06-27 (fedora - 01/12/10)
Section: 3 (Bibliothèques de fonctions)
Sommaire
NAME
Sprog::ClassFactory - simple dependency injection framework for SprogSYNOPSIS
To use all the default classes:use Sprog::ClassFactory; make_app()->run(@ARGV);
To override defaults:
make_app( '/app/view' => 'Sprog::TextView', # Yeah right )->run(@ARGV);
DESCRIPTION
This class provides a very simple framework for abstracting the building of classes for the Sprog application. The primary aim is to support the test suite.EXPORTED FUNCTIONS
make_app
This function is exported into the caller's namespace. It is usually called with no arguments and returns an application object of class Sprog. The application object is passed the factory object, which is used to create classes for the various components of the application.The default classes used for each component are hardcoded in the class that requires them. However, those defaults are passed through this factory class to provide a central location for declaring alternative classes.
METHODS
new ( path => class, ... )
The constructor is called automatically from "make_app" and returns a factory object which maps abstract paths of the form '/app/view' to concrete class names of the form 'Sprog::GtkView'.inject ( path => class, ... )
This method can be called at any time to add a new path to class mapping. If the specified path is already mapped to a class, this method will silently do nothing.override ( path => class, ... )
This method is exactly the same as "inject" except it will replace a path that is already mapped.make_class ( path, args )
Creates an object of the class defined for the specified path. Throws a fatal exception if no class is defined for "path". Any arguments are passed to the class constructor.load_class ( path )
Determines the class name for the specified path; "require"'s the class and returns its name. Useful for when you need to call methods in the class other than the constructor.COPYRIGHT
Copyright 2005 Grant McLean <grantm@cpan.org>This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre