From: Stevan Little Date: Wed, 21 Feb 2007 04:45:46 +0000 (+0000) Subject: More docs X-Git-Tag: 0_37~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=96e38ba61b74b11f7dea0abc194617d5bd8a8601;p=gitmo%2FClass-MOP.git More docs --- diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index 9b341f7..c7cd2fe 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -500,11 +500,6 @@ __END__ Class::MOP - A Meta Object Protocol for Perl 5 -=head1 SYNOPSIS - - # ... This will come later, for now see - # the other SYNOPSIS for more information - =head1 DESCRIPTON This module is an attempt to create a meta object protocol for the @@ -764,7 +759,7 @@ L =back -=head2 Article +=head2 Articles =over 4 diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index bde5f52..aaf904f 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -975,10 +975,16 @@ These are a few predicate methods for asking information about the class. =item B +This returns true if the class is a C created anon class. + =item B +This returns true if the class is still mutable. + =item B +This returns true if the class has been made immutable. + =back =head2 Inheritance Relationships @@ -1297,11 +1303,15 @@ It will return undef if nothing is found. =back -=head2 Class closing +=head2 Class Immutability =over 4 -=item B +=item B + +This method will invoke a tranforamtion upon the class which will +make it immutable. Details of this transformation can be found in +the L documentation. =back diff --git a/lib/Class/MOP/Immutable.pm b/lib/Class/MOP/Immutable.pm index 72a577a..5e6a3a6 100644 --- a/lib/Class/MOP/Immutable.pm +++ b/lib/Class/MOP/Immutable.pm @@ -194,30 +194,80 @@ Class::MOP::Immutable - A class to transform Class::MOP::Class metaclasses =head1 SYNOPSIS + use Class::MOP::Immutable; + + my $immutable_metaclass = Class::MOP::Immutable->new($metaclass, { + read_only => [qw/superclasses/], + cannot_call => [qw/ + add_method + alias_method + remove_method + add_attribute + remove_attribute + add_package_symbol + remove_package_symbol + /], + memoize => { + class_precedence_list => 'ARRAY', + compute_all_applicable_attributes => 'ARRAY', + get_meta_instance => 'SCALAR', + get_method_map => 'SCALAR', + } + }); + + $immutable_metaclass->make_metaclass_immutable(@_) + =head1 DESCRIPTION +This is basically a module for applying a transformation on a given +metaclass. Current features include making methods read-only, +making methods un-callable and memoizing methods (in a type specific +way too). + +This module is fairly new to the MOP, and quite possibly will be +expanded and further generalized as the need arises. + =head1 METHODS =over 4 -=item B - +=item B + +Given a C<$metaclass> and a set of C<%options> this module will +prepare an immutable version of the C<$metaclass>, which can then +be applied to the C<$metaclass> using the C +method. + =item B +Returns the options HASH set in C. + =item B +Returns the metaclass set in C. + =item B +Returns the immutable metaclass created within C. + =back =over 4 =item B +This will create the immutable version of the C<$metaclass>, but will +not actually change the original metaclass. + =item B +This will create all the methods for the immutable metaclass based +on the C<%options> passed into C. + =item B +This will actually change the C<$metaclass> into the immutable version. + =back =head1 AUTHORS diff --git a/lib/Class/MOP/Method/Accessor.pm b/lib/Class/MOP/Method/Accessor.pm index 7087047..36b29a4 100644 --- a/lib/Class/MOP/Method/Accessor.pm +++ b/lib/Class/MOP/Method/Accessor.pm @@ -188,24 +188,79 @@ Class::MOP::Method::Accessor - Method Meta Object for accessors =head1 SYNOPSIS - # ... more to come later maybe + use Class::MOP::Method::Accessor; + + my $reader = Class::MOP::Method::Accessor->new( + attribute => $attribute, + is_inline => 1, + accessor_type => 'reader', + ); + + $reader->body->($instance); # call the reader method =head1 DESCRIPTION +This is a C subclass which is used interally +by C to generate accessor code. It can +handle generation of readers, writers, predicate and clearer +methods, both as closures and as more optimized inline methods. + =head1 METHODS =over 4 -=item B +=item B -=item B +This creates the method based on the criteria in C<%options>, +these options are: + +=over 4 + +=item I + +This must be an instance of C which this +accessor is being generated for. This paramter is B. + +=item I + +This is a string from the following set; reader, writer, accessor, +predicate or clearer. This is used to determine which type of +method is to be generated. + +=item I + +This is a boolean to indicate if the method should be generated +as a closure, or as a more optimized inline version. + +=back =item B +This returns the accessor type which was passed into C. + =item B +This returns the boolean which was passed into C. + =item B +This returns the attribute instance which was passed into C. + +=item B + +This will actually generate the method based on the specified +criteria passed to the constructor. + +=back + +=head2 Method Generators + +These methods will generate appropriate code references for +the various types of accessors which are supported by +C. The names pretty much explain it all. + +=over 4 + =item B =item B diff --git a/lib/Class/MOP/Method/Constructor.pm b/lib/Class/MOP/Method/Constructor.pm index fcff479..7f7cb81 100644 --- a/lib/Class/MOP/Method/Constructor.pm +++ b/lib/Class/MOP/Method/Constructor.pm @@ -33,7 +33,6 @@ sub new { # we don't want this creating # a cycle in the code, if not # needed -# weaken($self->{'$!meta_instance'}); weaken($self->{'$!associated_metaclass'}); $self->intialize_body; @@ -137,26 +136,56 @@ Class::MOP::Method::Constructor - Method Meta Object for constructors =head1 SYNOPSIS + use Class::MOP::Method::Constructor; + + my $constructor = Class::MOP::Method::Constructor->new( + metaclass => $metaclass, + options => { + debug => 1, # this is all for now + }, + ); + + # calling the constructor ... + $constructor->body->($metaclass->name, %params); + =head1 DESCRIPTION +This is a subclass of C which deals with +class constructors. + =head1 METHODS =over 4 -=item B +=item B $meta, options => \%options)> -=item B +=item B + +This returns the options HASH which is passed into C. + +=item B + +This returns the metaclass which is passed into C. =item B +This returns the list of attributes which are associated with the +metaclass which is passed into C. + =item B -=item B +This returns the meta instance which is associated with the +metaclass which is passed into C. -=item B +=item B + +This returns a boolean, but since constructors are very rarely +not inlined, this always returns true for now. =item B +This creates the code reference for the constructor itself. + =back =head1 AUTHORS diff --git a/lib/Class/MOP/Module.pm b/lib/Class/MOP/Module.pm index d992080..291606b 100644 --- a/lib/Class/MOP/Module.pm +++ b/lib/Class/MOP/Module.pm @@ -69,7 +69,7 @@ package for the given instance. =item B -This constructs a string of the name, version and authrity. +This constructs a string of the name, version and authority. =back