NAME
Moose::Meta::Class - The Moose metaclass
DESCRIPTION
This is a subclass of Class::MOP::Class with Moose specific extensions.
For the most part, the only time you will ever encounter an instance of this class is if you are doing some serious deep introspection. To really understand this class, you need to refer to the Class::MOP::Class documentation.
METHODS
- initialize
- create
-
Overrides original to accept a list of roles to apply to the created class.
my $metaclass = Moose::Meta::Class->create( 'New::Class', roles => [...] );
- create_anon_class
-
Overrides original to support roles and caching.
my $metaclass = Moose::Meta::Class->create_anon_class( superclasses => ['Foo'], roles => [qw/Some Roles Go Here/], cache => 1, );
- make_immutable
-
Override original to add default options for inlining destructor and altering the Constructor metaclass.
- create_immutable_transformer
-
Override original to lock
add_role
and memoizecalculate_all_roles
- new_object
-
We override this method to support the
trigger
attribute option. - construct_instance
-
This provides some Moose specific extensions to this method, you almost never call this method directly unless you really know what you are doing.
This method makes sure to handle the moose weak-ref, type-constraint and type coercion features.
- get_method_map
-
This accommodates Moose::Meta::Role::Method instances, which are aliased, instead of added, but still need to be counted as valid methods.
- add_override_method_modifier ($name, $method)
-
This will create an
override
method modifier for you, and install it in the package. - add_augment_method_modifier ($name, $method)
-
This will create an
augment
method modifier for you, and install it in the package. - calculate_all_roles
- roles
-
This will return an array of
Moose::Meta::Role
instances which are attached to this class. - add_role ($role)
-
This takes an instance of
Moose::Meta::Role
in$role
, and adds it to the list of associated roles. - does_role ($role_name)
-
This will test if this class
does
a given$role_name
. It will not only check it's local roles, but ask them as well in order to cascade down the role hierarchy. - excludes_role ($role_name)
-
This will test if this class
excludes
a given$role_name
. It will not only check it's local roles, but ask them as well in order to cascade down the role hierarchy. - add_attribute ($attr_name, %params|$params)
-
This method does the same thing as Class::MOP::Class::add_attribute, but adds support for taking the
$params
as a HASH ref. - constructor_class ($class_name)
- destructor_class ($class_name)
-
These are the names of classes used when making a class immutable. These default to Moose::Meta::Method::Constructor and Moose::Meta::Method::Destructor respectively. These accessors are read-write, so you can use them to change the class name.
- error_class ($class_name)
-
The name of the class used to throw errors. This default to Moose::Error::Default, which generates an error with a stacktrace just like
Carp::confess
. - check_metaclass_compatibility
-
Moose overrides this method from
Class::MOP::Class
and attempts to fix some incompatibilities before doing the check. - throw_error $message, %extra
-
Throws the error created by
create_error
usingraise_error
- create_error $message, %extra
-
Creates an error message or object.
The default behavior is
create_error_confess
.If
error_class
is set usescreate_error_object
. Otherwise useserror_builder
(a code reference or variant name), and calls the appropriatecreate_error_$builder
method. - error_builder $builder_name
-
Get or set the error builder. Defaults to
confess
. - error_class $class_name
-
Get or set the error class. Has no default.
- create_error_confess %args
-
Creates an error using "longmess" in Carp
- create_error_croak %args
-
Creates an error using "shortmess" in Carp
- create_error_object %args
-
Calls
new
on theclass
parameter in%args
. Usable witherror_class
to support custom error objects for your meta class. - raise_error $error
-
Dies with an error object or string.
BUGS
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.
AUTHOR
Stevan Little <stevan@iinteractive.com>
COPYRIGHT AND LICENSE
Copyright 2006-2008 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.