NAME
Launcher::Cascade - a base class for Launcher::Cascade::*
SYNOPSIS
use base qw( Launcher::Cascade );
Launcher::Cascade::make_accessor qw( first_name last_name );
Launcher::Cascade::make_accessors_with_defaults(age => 18);
DESCRIPTION
This base class provides a constructor for its subclasses that accepts named arguments, as well as function to easily create attributes and their accessors. All the real functionality has to be implemented in subclasses.
Constructor
- new LIST
-
Creates and returns an instance. LIST should be a list of named parameters. The values will be passed to the accessors of the same name. Leading dashes will be removed from the names, and they will be converted to lowercase before invoking the accessor.
Functions
- make_accessors LIST
-
Make accessors in the caller's namespace.
LIST should contain names of accessors. make_accessors() will generate an accessor for each name in LIST, that will return the corresponding attribute's value when called without argument, and set the attribute's value when called with an argument (in that latter case, the former value is returned). Example:
package MyPackage; use Launcher::Cascade; our @ISA = qw/ Launcher::Cascade /; # inherits constructor Launcher::Cascade::make_accessors qw/ first_name last_name /; 1;
Meanwhile, in a nearby piece of code:
use MyPackage; my $object = new MyPackage -first_name => 'Zaphod'; print $object->first_name(); # Zaphod print $object->last_name('Beeblebrox'); # undef print $object->last_name(); # Beeblebrox
- read_default_file FILENAME
-
Reads a file containing the definition of default values for subclasses attributes. The file should contain name, value pairs, one by line, separated by an equal sign. Whitespace is ignored at the beginning or end of the line and on either side of the equal sign. Lines starting with a hash sign are ignored, as well as blank lines.
The name should be the fully qualified accessor method name, i.e., the package and name of the accessor separated by a double colon.
# This is an example MyPackage::first_name = Zaphod MyPackage::last_name = Beeblebrox
- make_accessors_with_defaults LIST
-
Does the same as make_accessors(), but elements in LIST should go in pairs, accessor names together with their default values. If the attribute's value has not explicitly been set, the accessor will return the default value as read from the defaults file (see read_default_file()) or the default value provided in LIST. The defaults file overrides the value from LIST.
package MyPackage; use Launcher::Cascade; our @ISA = qw/ Launcher::Cascade /; Launcher::Cascade::make_accessors_with_defaults( first_name => 'Zaphod', last_name => 'Beeblebrox', );
Meanwhile, in a nearby piece of code:
use MyPackage; my $o = new MyPackage; print $o->first_name(); # Zaphod
VERSION
0.01
SEE ALSO
AUTHOR
Cédric Bouvier <cbouvi@cpan.org>
COPYRIGHT & LICENSE
Copyright (C) 2006 Cédric Bouvier, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 197:
Non-ASCII character seen before =encoding in 'Cédric'. Assuming CP1252