Class::Meta::Constructor - Class::Meta class constructor introspection
# Assuming MyApp::Thingy was generated by Class::Meta. my $class = MyApp::Thingy->my_class; print "\nConstructors:\n"; for my $ctor ($class->constructors) { print " o ", $ctor->name, $/; my $thingy = $ctor->call; }
This class provides an interface to the Class::Meta objects that describe class constructors. It supports a simple description of the constructor, a label, and the constructor visibility (private, protected, or public).
Class::Meta
Class::Meta::Constructor objects are created by Class::Meta; they are never instantiated directly in client code. To access the constructor objects for a Class::Meta-generated class, simply call its my_class() method to retrieve its Class::Meta::Class object, and then call the constructors() method on the Class::Meta::Class object.
my_class()
constructors()
A protected method for constructing a Class::Meta::Constructor object. Do not call this method directly; Call the add_constructor() method on a Class::Meta object, instead.
add_constructor()
my $name = $ctor->name;
Returns the constructor name.
my $package = $ctor->package;
Returns the package name of the class that constructor is associated with.
my $desc = $ctor->desc;
Returns the description of the constructor.
my $desc = $ctor->label;
Returns label for the constructor.
my $view = $ctor->view;
Returns the view of the constructor, reflecting its visibility. The possible values are defined by the following constants:
my $class = $attr->class;
Returns the Class::Meta::Class object that this constructor is associated with. Note that this object will always represent the class in which the constructor is defined, and not any of its subclasses.
my $obj = $ctor->call(@params);
Executes the constructor for the class, passing the parameters to it. Note that it uses a goto to execute the constructor, so the call to call() itself will not appear in a call stack trace.
goto
call()
$ctor->build($class);
This is a protected method, designed to be called only by the Class::Meta class or a subclass of Class::Meta. It takes a single argument, the Class::Meta::Class object for the class in which the attribute was defined, and generates constructor methods for the Class::Meta::Constructor object.
Although you should never call this method directly, subclasses of Class::Meta::Attribute may need to override its behavior.
Please report all bugs via the CPAN Request Tracker at http://rt.cpan.org/NoAuth/Bugs.html?Dist=Class-Meta.
David Wheeler <david@kineticode.com>
Other classes of interest within the Class::Meta distribution include:
Copyright (c) 2002-2004, David Wheeler. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Class::Meta, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Meta
CPAN shell
perl -MCPAN -e shell install Class::Meta
For more information on module installation, please visit the detailed CPAN module installation guide.