02 Mar 2010 13:00:15 UTC
- Distribution: Object-Composer
- Module version: 0.0.2
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (470 / 0 / 0)
- KwaliteeBus factor: 0
- License: unknown
- Download (21.88KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
Object::Composer - Simple helper to load classes automatically and instantiate them
use Object::Composer; my $neo = load 'My::Person', name => 'Neo', job => 'Hacker', age => 'NA'; # OR ( if you don't want import functions into your space ) use Object::Composer (); my $morpheus = Object::Composer->load( 'My::Person', name => 'morpheus', job => 'warrior', age => 'NA' ); # OR ( You can call it as Class Method or as Function in Object::Composer's namespace ) my $morpheus = Object::Composer::load( 'My::Person', name => 'morpheus', job => 'warrior', age => 'NA' );
This is a simple helper class that helps loading class automatically, instantiate an object and return it. It assumes that 'new' method is already defined in the loaded class, which is what it calls to instantiate the object.
croaks if theres any error while loading or instantiating.
This is the only function / method defined. It loads the package / module, calls "new" on the class with arguments you pass, and returns the instantiated object.
$obj = load 'LWP::UserAgent', agent => 'My Own Secret Agent'; # OR $obj = Object::Composer->load( 'HTML::TreeBuilder' );
Venkatakrishnan Ganesh <email@example.com>
This library is free software and may be distributed under the same terms as perl itself.
Module Install Instructions
To install Object::Composer, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Object::Composer
For more information on module installation, please visit the detailed CPAN module installation guide.
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|