X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FClass.pm;h=d7317fe039b43e92c1f62b4754ed398fefd9b114;hb=70bb0f972929efcf64ea1a28efb272cf6334d17f;hp=07c903ad6364830c9ba103c92eaa425ab32abef7;hpb=a532c4ac93ebdcbd09cd455dbb49caf8a7de1912;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 07c903a..d7317fe 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -11,7 +11,7 @@ use List::Util qw( first ); use List::MoreUtils qw( any all uniq ); use Scalar::Util 'weaken', 'blessed'; -our $VERSION = '0.71_01'; +our $VERSION = '0.72'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -379,7 +379,7 @@ sub _find_common_ancestor { # FIXME? This doesn't account for multiple inheritance (not sure # if it needs to though). For example, is somewhere in $meta1's - # history it inherits from both ClassA and ClassB, and $meta + # history it inherits from both ClassA and ClassB, and $meta2 # inherits from ClassB & ClassA, does it matter? And what crazy # fool would do that anyway? @@ -636,163 +636,116 @@ Moose::Meta::Class - The Moose metaclass =head1 DESCRIPTION -This is a subclass of L with Moose specific -extensions. +This class is a subclass of L that provides +additional Moose-specific functionality. -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 L documentation. +To really understand this class, you will probably need to start with +the L documentation. This class can be understood +as a set of additional features on top of the basic feature provided +by that parent class. =head1 METHODS =over 4 -=item B +=item B<< Moose::Meta::Class->initialize($package_name, %options) >> -=item B +This overrides the parent's method in order to provide its own +defaults for the C, C, and +C options. -Overrides original to accept a list of roles to apply to -the created class. +These all default to the appropriate Moose class. - my $metaclass = Moose::Meta::Class->create( 'New::Class', roles => [...] ); +=item B<< Moose::Meta::Class->create($package_name, %options) >> -=item B +This overrides the parent's method in order to accept a C +option. This should be an array reference containing one more roles +that the class does. -Overrides original to support roles and caching. + my $metaclass = Moose::Meta::Class->create( 'New::Class', roles => [...] ); - my $metaclass = Moose::Meta::Class->create_anon_class( - superclasses => ['Foo'], - roles => [qw/Some Roles Go Here/], - cache => 1, - ); +=item B<< Moose::Meta::Class->create_anon_class >> -=item B +This overrides the parent's method to accept a C option, just +as C does. -Override original to add default options for inlining destructor -and altering the Constructor metaclass. +It also accepts a C 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. -=item B + my $metaclass = Moose::Meta::Class->create_anon_class( + superclasses => ['Foo'], + roles => [qw/Some Roles Go Here/], + cache => 1, + ); -Override original to lock C and memoize C +=item B<< $metaclass->make_immutable(%options) >> -=item B +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. -We override this method to support the C attribute option. +Also, since Moose always inlines attributes, it sets the +C option to false. -=item B +=item B<< $metaclass->new_object(%params) >> -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 overrides the parent's method in order to add support for +attribute triggers. -This method makes sure to handle the moose weak-ref, type-constraint -and type coercion features. +=item B<< $metaclass->add_override_method_modifier($name, $sub) >> -=item B +This adds an C method modifier to the package. -This accommodates Moose::Meta::Role::Method instances, which are -aliased, instead of added, but still need to be counted as valid -methods. +=item B<< $metaclass->add_augment_method_modifier($name, $sub) >> -=item B +This adds an C method modifier to the package. -This will create an C method modifier for you, and install -it in the package. +=item B<< $metaclass->calculate_all_roles >> -=item B +This will return a unique array of C instances +which are attached to this class. -This will create an C method modifier for you, and install -it in the package. +=item B<< $metaclass->add_role($role) >> -=item B +This takes a L object, and adds it to the class's +list of roles. This I actually apply the role to the class. -=item B +=item B<< $metaclass->does_role($role_name) >> -This will return an array of C instances which are -attached to this class. +This returns a boolean indicating whether or not the class does the +specified role. This tests both the class and its parents. -=item B +=item B<< $metaclass->excludes_role($role_name) >> -This takes an instance of C in C<$role>, and adds it -to the list of associated roles. +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. -=item B +=item B<< $metaclass->add_attribute($attr_name, %params|$params) >> -This will test if this class C a given C<$role_name>. It will -not only check it's local roles, but ask them as well in order to -cascade down the role hierarchy. +This overrides the parent's method in order to allow the parameters to +be provided as a hash reference. -=item B +=item B<< $metaclass->constructor_class ($class_name) >> -This will test if this class C a given C<$role_name>. It will -not only check it's local roles, but ask them as well in order to -cascade down the role hierarchy. - -=item B - -This method does the same thing as L, but adds -support for taking the C<$params> as a HASH ref. - -=item B - -=item B +=item B<< $metaclass->destructor_class ($class_name) >> These are the names of classes used when making a class immutable. These default to L and L respectively. These accessors are read-write, so you can use them to change the class name. -=item B +=item B<< $metaclass->error_class($class_name) >> -The name of the class used to throw errors. This default to +The name of the class used to throw errors. This defaults to L, which generates an error with a stacktrace just like C. -=item B - -Moose overrides this method from C and attempts to -fix some incompatibilities before doing the check. - -=item B +=item B<< $metaclass->throw_error($message, %extra) >> Throws the error created by C using C -=item B - -Creates an error message or object. - -The default behavior is C. - -If C is set uses C. Otherwise uses -C (a code reference or variant name), and calls the appropriate -C method. - -=item B - -Get or set the error builder. Defaults to C. - -=item B - -Get or set the error class. This defaults to L. - -=item B - -Creates an error using L - -=item B - -Creates an error using L - -=item B - -Calls C on the C parameter in C<%args>. Usable with C -to support custom error objects for your meta class. - -=item B - -Dies with an error object or string. - =back =head1 BUGS