The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Moose::Meta::Class - The Moose metaclass

DESCRIPTION

This class is a subclass of Class::MOP::Class that provides additional Moose-specific functionality.

To really understand this class, you will need to start with the Class::MOP::Class documentation. This class can be understood as a set of additional features on top of the basic feature provided by that parent class.

INHERITANCE

Moose::Meta::Class is a subclass of Class::MOP::Class.

METHODS

Moose::Meta::Class->initialize($package_name, %options)

This overrides the parent's method in order to provide its own defaults for the attribute_metaclass, instance_metaclass, and method_metaclass options.

These all default to the appropriate Moose class.

Moose::Meta::Class->create($package_name, %options)

This overrides the parent's method in order to accept a roles option. This should be an array reference containing one more roles that the class does.

  my $metaclass = Moose::Meta::Class->create( 'New::Class', roles => [...] );
Moose::Meta::Class->create_anon_class

This overrides the parent's method to accept a roles option, just as create does.

It also accepts a cache option. If this is true, then the anonymous class will be cached based on its superclasses and roles. If an existing anonymous class in the cache has the same superclasses and roles, it will be reused.

  my $metaclass = Moose::Meta::Class->create_anon_class(
      superclasses => ['Foo'],
      roles        => [qw/Some Roles Go Here/],
      cache        => 1,
  );
$metaclass->make_immutable(%options)

This overrides the parent's method to add a few options. Specifically, it uses the Moose-specific constructor and destructor classes, and enables inlining the destructor.

Also, since Moose always inlines attributes, it sets the inline_accessors option to false.

$metaclass->new_object(%params)

This overrides the parent's method in order to add support for attribute triggers.

$metaclass->add_override_method_modifier($name, $sub)

This adds an override method modifier to the package.

$metaclass->add_augment_method_modifier($name, $sub)

This adds an augment method modifier to the package.

$metaclass->calculate_all_roles

This will return a unique array of Moose::Meta::Role instances which are attached to this class.

$metaclass->add_role($role)

This takes a Moose::Meta::Role object, and adds it to the class's list of roles. This does not actually apply the role to the class.

$metaclass->role_applications

Returns a list of Moose::Meta::Role::Application::ToClass objects, which contain the arguments to role application.

$metaclass->add_role_application($application)

This takes a Moose::Meta::Role::Application::ToClass object, and adds it to the class's list of role applications. This does not actually apply any role to the class; it is only for tracking role applications.

$metaclass->does_role($role_name)

This returns a boolean indicating whether or not the class does the specified role. This tests both the class and its parents.

$metaclass->excludes_role($role_name)

A class excludes a role if it has already composed a role which excludes the named role. This tests both the class and its parents.

$metaclass->add_attribute($attr_name, %params|$params)

This overrides the parent's method in order to allow the parameters to be provided as a hash reference.

$metaclass->constructor_class ($class_name)
$metaclass->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.

$metaclass->error_class($class_name)

The name of the class used to throw errors. This defaults to Moose::Error::Default, which generates an error with a stacktrace just like Carp::confess.

$metaclass->throw_error($message, %extra)

Throws the error created by create_error using raise_error

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-2009 by Infinity Interactive, Inc.

http://www.iinteractive.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.