1Moose::Meta::Class(3) User Contributed Perl DocumentationMoose::Meta::Class(3)
2
3
4

NAME

6       Moose::Meta::Class - The Moose metaclass
7

VERSION

9       version 2.2201
10

DESCRIPTION

12       This class is a subclass of Class::MOP::Class that provides additional
13       Moose-specific functionality.
14
15       To really understand this class, you will need to start with the
16       Class::MOP::Class documentation. This class can be understood as a set
17       of additional features on top of the basic feature provided by that
18       parent class.
19

INHERITANCE

21       "Moose::Meta::Class" is a subclass of Class::MOP::Class.
22

METHODS

24       Moose::Meta::Class->initialize($package_name, %options)
25           This overrides the parent's method in order to provide its own
26           defaults for the "attribute_metaclass", "instance_metaclass", and
27           "method_metaclass" options.
28
29           These all default to the appropriate Moose class.
30
31       Moose::Meta::Class->create($package_name, %options)
32           This overrides the parent's method in order to accept a "roles"
33           option. This should be an array reference containing roles that the
34           class does, each optionally followed by a hashref of options
35           ("-excludes" and "-alias").
36
37             my $metaclass = Moose::Meta::Class->create( 'New::Class', roles => [...] );
38
39       Moose::Meta::Class->create_anon_class
40           This overrides the parent's method to accept a "roles" option, just
41           as "create" does.
42
43           It also accepts a "cache" option. If this is "true", then the
44           anonymous class will be cached based on its superclasses and roles.
45           If an existing anonymous class in the cache has the same
46           superclasses and roles, it will be reused.
47
48             my $metaclass = Moose::Meta::Class->create_anon_class(
49                 superclasses => ['Foo'],
50                 roles        => [qw/Some Roles Go Here/],
51                 cache        => 1,
52             );
53
54           Each entry in both the "superclasses" and the "roles" option can be
55           followed by a hash reference with arguments. The "superclasses"
56           option can be supplied with a -version option that ensures the
57           loaded superclass satisfies the required version. The "role" option
58           also takes the "-version" as an argument, but the option hash
59           reference can also contain any other role relevant values like
60           exclusions or parameterized role arguments.
61
62       $metaclass->new_object(%params)
63           This overrides the parent's method in order to add support for
64           attribute triggers.
65
66       $metaclass->superclasses(@superclasses)
67           This is the accessor allowing you to read or change the parents of
68           the class.
69
70           Each superclass can be followed by a hash reference containing a
71           -version value. If the version requirement is not satisfied an
72           error will be thrown.
73
74           When you pass classes to this method, we will attempt to load them
75           if they are not already loaded.
76
77       $metaclass->add_override_method_modifier($name, $sub)
78           This adds an "override" method modifier to the package.
79
80       $metaclass->add_augment_method_modifier($name, $sub)
81           This adds an "augment" method modifier to the package.
82
83       $metaclass->calculate_all_roles
84           This will return a unique array of Moose::Meta::Role instances
85           which are attached to this class.
86
87       $metaclass->calculate_all_roles_with_inheritance
88           This will return a unique array of Moose::Meta::Role instances
89           which are attached to this class, and each of this class's
90           ancestors.
91
92       $metaclass->add_role($role)
93           This takes a Moose::Meta::Role object, and adds it to the class's
94           list of roles. This does not actually apply the role to the class.
95
96       $metaclass->role_applications
97           Returns a list of Moose::Meta::Role::Application::ToClass objects,
98           which contain the arguments to role application.
99
100       $metaclass->add_role_application($application)
101           This takes a Moose::Meta::Role::Application::ToClass object, and
102           adds it to the class's list of role applications. This does not
103           actually apply any role to the class; it is only for tracking role
104           applications.
105
106       $metaclass->does_role($role)
107           This returns a boolean indicating whether or not the class does the
108           specified role. The role provided can be either a role name or a
109           Moose::Meta::Role object. This tests both the class and its
110           parents.
111
112       $metaclass->excludes_role($role_name)
113           A class excludes a role if it has already composed a role which
114           excludes the named role. This tests both the class and its parents.
115
116       $metaclass->add_attribute($attr_name, %params|$params)
117           This overrides the parent's method in order to allow the parameters
118           to be provided as a hash reference.
119
120       $metaclass->constructor_class($class_name)
121       $metaclass->destructor_class($class_name)
122           These are the names of classes used when making a class immutable.
123           These default to Moose::Meta::Method::Constructor and
124           Moose::Meta::Method::Destructor respectively. These accessors are
125           read-write, so you can use them to change the class name.
126

BUGS

128       See "BUGS" in Moose for details on reporting bugs.
129

AUTHORS

131       •   Stevan Little <stevan@cpan.org>
132
133       •   Dave Rolsky <autarch@urth.org>
134
135       •   Jesse Luehrs <doy@cpan.org>
136
137       •   Shawn M Moore <sartak@cpan.org>
138
139       •   יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
140
141       •   Karen Etheridge <ether@cpan.org>
142
143       •   Florian Ragwitz <rafl@debian.org>
144
145       •   Hans Dieter Pearcey <hdp@cpan.org>
146
147       •   Chris Prather <chris@prather.org>
148
149       •   Matt S Trout <mstrout@cpan.org>
150
152       This software is copyright (c) 2006 by Infinity Interactive, Inc.
153
154       This is free software; you can redistribute it and/or modify it under
155       the same terms as the Perl 5 programming language system itself.
156
157
158
159perl v5.34.0                      2022-01-21             Moose::Meta::Class(3)
Impressum