Constructorsnew
A protected method for constructing a Class::Meta::Attribute object. Do not call this method directly;
Call the add_attribute() method on a Class::Meta object, instead.
InstanceMethodsname
my $name = $attr->name;
Returns the name of the attribute.
type
my $type = $attr->type;
Returns the name of the attribute's data type. Typical values are "scalar", "string", and "boolean". See
Class::Meta for a complete list.
is
if ($attr->is('string')) {
# ...
}
A convenience method for "$attr->type eq $type".
desc
my $desc = $attr->desc;
Returns a description of the attribute.
label
my $label = $attr->label;
Returns a label for the attribute, suitable for use in a user interface. It is distinguished from the
attribute name, which functions to name the accessor methods for the attribute.
required
my $req = $attr->required;
Indicates if the attribute is required to have a value.
once
my $once = $attr->once;
Indicates whether an attribute value can be set to a defined value only once.
package
my $package = $attr->package;
Returns the package name of the class that attribute is associated with.
view
my $view = $attr->view;
Returns the view of the attribute, reflecting its visibility. The possible values are defined by the
following constants:
Class::Meta::PUBLIC
Class::Meta::PRIVATE
Class::Meta::TRUSTED
Class::Meta::PROTECTED
context
my $context = $attr->context;
Returns the context of the attribute, essentially whether it is a class or object attribute. The possible
values are defined by the following constants:
Class::Meta::CLASS
Class::Meta::OBJECT
authz
my $authz = $attr->authz;
Returns the authorization for the attribute, which determines whether it can be read or changed. The
possible values are defined by the following constants:
Class::Meta::READ
Class::Meta::WRITE
Class::Meta::RDWR
Class::Meta::NONE
class
my $class = $attr->class;
Returns the Class::Meta::Class object that this attribute is associated with. Note that this object will
always represent the class in which the attribute is defined, and not any of its subclasses.
default
my $default = $attr->default;
Returns the default value for a new instance of this attribute. Since the default value can be determined
dynamically, the value returned by default() may change on subsequent calls. It all depends on what was
passed for the "default" parameter in the call to add_attribute() on the Class::Meta object that
generated the class.
get
my $value = $attr->get($thingy);
This method calls the "get" accessor method on the object passed as the sole argument and returns the
value of the attribute for that object. Note that it uses a "goto" to execute the accessor, so the call
to set() itself will not appear in a call stack trace.
set
$attr->set($thingy, $new_value);
This method calls the "set" accessor method on the object passed as the first argument and passes any
remaining arguments to assign a new value to the attribute for that object. Note that it uses a "goto" to
execute the accessor, so the call to set() itself will not appear in a call stack trace.
build
$attr->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 attribute accessors by calling out to the make_attr_get() and
make_attr_set() methods of Class::Meta::Type as appropriate for the Class::Meta::Attribute object.
Although you should never call this method directly, subclasses of Class::Meta::Constructor may need to
override its behavior.