From: Dave Rolsky Date: Sat, 21 Mar 2009 14:30:17 +0000 (-0500) Subject: Revamped Moose::Meta::Class docs and updated coverage & spelling lists X-Git-Tag: 0.72_01~52 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=70bb0f972929efcf64ea1a28efb272cf6334d17f;p=gitmo%2FMoose.git Revamped Moose::Meta::Class docs and updated coverage & spelling lists I'm explicitly not documenting the error related methods for now. I think they need some review before we try to document them for end user use. --- diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 06272bc..d7317fe 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -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 diff --git a/xt/pod_coverage.t b/xt/pod_coverage.t index 8e15c61..5978c22 100644 --- a/xt/pod_coverage.t +++ b/xt/pod_coverage.t @@ -16,11 +16,29 @@ plan tests => scalar @modules; my %trustme = ( 'Moose' => ['make_immutable'], 'Moose::Meta::Attribute' => [ 'interpolate_class', 'throw_error' ], + 'Moose::Meta::Class' => [ + qw( check_metaclass_compatibility + construct_instance + create_error + create_immutable_transformer + raise_error + ) + ], 'Moose::Meta::Method::Constructor' => [qw( initialize_body intialize_body)], 'Moose::Meta::Method::Destructor' => ['initialize_body'], 'Moose::Role' => [ - qw( after around augment before extends has inner make_immutable override super with ) + qw( after + around + augment + before + extends + has + inner + make_immutable + override + super + with ) ], ); diff --git a/xt/pod_spell.t b/xt/pod_spell.t index ca8e0ac..0a32aaa 100644 --- a/xt/pod_spell.t +++ b/xt/pod_spell.t @@ -119,6 +119,7 @@ hashrefs immutabilize immutabilized inline +inlines invocant invocant's irc @@ -129,6 +130,8 @@ namespace namespaced namespaces namespacing +# as in required-ness +ness OO OOP ORM @@ -153,6 +156,7 @@ UNIMPORTING Unported unsets unsettable +whitelist Whitelist ## other jargon