From: Stevan Little Date: Sun, 7 May 2006 02:15:12 +0000 (+0000) Subject: changes-and-comments X-Git-Tag: 0_09_03~35 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=98aae381810712cc4d2c58e1dd8b401abf7c4d6c;p=gitmo%2FMoose.git changes-and-comments --- diff --git a/Changes b/Changes index 09c368d..1835254 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,38 @@ Revision history for Perl extension Moose +0.06 + * Moose + - refactored the keyword exports + - 'with' now checks Role validaity + - 'extends' makes metaclass adjustments as + needed to ensure metaclass compatability + + * Moose::Util::TypeConstraints + - added the 'enum' keyword for simple + string enumerations which can be used as + type constraints + - see example of usage in t/008_basic.t + + * Moose::Object + - more careful checking of params to new() + + * Moose::Meta::Instance + - added new Instance metaclass to support + the new Class::MOP instance protocol + + * Moose::Meta::Class + - some small changes to support the new + instance protocol + + * Moose::Meta::Attribute + - some improvements to the accessor generation code + by nothingmuch + - some small changes to support the new + instance protocol + - (still somewhat) experimental delegation support + with the 'handles' option + - added several tests for this + 0.05 Thurs. April 27, 2006 * Moose - keywords are now exported with Sub::Exporter diff --git a/TODO b/TODO index c03ea5f..c5c7173 100644 --- a/TODO +++ b/TODO @@ -19,16 +19,6 @@ Mostly just for Roles [10:49] stevan does can be added to,.. but not changed -- triggers - -[18:18] mst what I'd really like is just to say trigger => 'some_method' - -- attribute delgates - -Introduce capability to control the generated wrapper. Useful for when you have -a wrapper that should implement the interface of it's child, but decorate with -more metadata. - - proxy attributes [15:49] stevan you want a proxied attribute diff --git a/lib/Moose.pm b/lib/Moose.pm index 33fd12a..a7541ba 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -186,9 +186,6 @@ use Moose::Util::TypeConstraints; }, blessed => sub { return \&Scalar::Util::blessed; - }, - all_methods => sub { - subname 'Moose::all_methods' => sub () { qr/.*/ } } ); @@ -547,6 +544,8 @@ to cpan-RT. Stevan Little Estevan@iinteractive.comE +Christian Hansen + =head1 COPYRIGHT AND LICENSE Copyright 2006 by Infinity Interactive, Inc. diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 14036a1..fffe5e7 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -15,18 +15,9 @@ use base 'Class::MOP::Attribute'; # options which are not directly used # but we store them for metadata purposes -__PACKAGE__->meta->add_attribute('isa' => ( - reader => 'isa_metadata', - predicate => 'has_isa_metadata', -)); -__PACKAGE__->meta->add_attribute('does' => ( - reader => 'does_metadata', - predicate => 'has_does_metadata', -)); -__PACKAGE__->meta->add_attribute('is' => ( - reader => 'is_metadata', - predicate => 'has_is_metadata', -)); +__PACKAGE__->meta->add_attribute('isa' => (reader => '_isa_metadata')); +__PACKAGE__->meta->add_attribute('does' => (reader => '_does_metadata')); +__PACKAGE__->meta->add_attribute('is' => (reader => '_is_metadata')); # these are actual options for the attrs __PACKAGE__->meta->add_attribute('required' => (reader => 'is_required' )); @@ -50,8 +41,7 @@ __PACKAGE__->meta->add_attribute('handles' => ( sub new { my ($class, $name, %options) = @_; $class->_process_options($name, \%options); - my $self = $class->SUPER::new($name, %options); - return $self; + return $class->SUPER::new($name, %options); } sub clone_and_inherit_options { @@ -98,15 +88,15 @@ sub _process_options { } elsif ($options->{is} eq 'rw') { $options->{accessor} = $name; + ((reftype($options->{trigger}) || '') eq 'CODE') + || confess "Trigger must be a CODE ref" + if exists $options->{trigger}; } else { confess "I do not understand this option (is => " . $options->{is} . ")" } } - # process and check trigger here ... - - if (exists $options->{isa}) { if (exists $options->{does}) { @@ -403,6 +393,8 @@ sub install_accessors { return; } +# private methods to help delegation ... + sub _canonicalize_handles { my $self = shift; my $handles = $self->handles; @@ -428,8 +420,7 @@ sub _canonicalize_handles { sub _find_delegate_metaclass { my $self = shift; - if ($self->has_isa_metadata) { - my $class = $self->isa_metadata; + if (my $class = $self->_isa_metadata) { # if the class does have # a meta method, use it return $class->meta if $class->can('meta'); @@ -439,10 +430,10 @@ sub _find_delegate_metaclass { # our own metaclass return Moose::Meta::Class->initialize($class); } - elsif ($self->has_does_metadata) { + elsif (my $role = $self->_does_metadata) { # our role will always have # a meta method - return $self->does_metadata->meta; + return $role->meta; } else { confess "Cannot find delegate metaclass for attribute " . $self->name; @@ -585,6 +576,8 @@ to cpan-RT. Stevan Little Estevan@iinteractive.comE +Yuval Kogman Enothingmuch@woobling.comE + =head1 COPYRIGHT AND LICENSE Copyright 2006 by Infinity Interactive, Inc. diff --git a/lib/Moose/Meta/Instance.pm b/lib/Moose/Meta/Instance.pm index 1946275..dde645e 100644 --- a/lib/Moose/Meta/Instance.pm +++ b/lib/Moose/Meta/Instance.pm @@ -32,6 +32,8 @@ to cpan-RT. Stevan Little Estevan@iinteractive.comE +Yuval Kogman Enothingmuch@woobling.comE + =head1 COPYRIGHT AND LICENSE Copyright 2006 by Infinity Interactive, Inc. diff --git a/lib/Moose/Role.pm b/lib/Moose/Role.pm index 9671f3a..aa27617 100644 --- a/lib/Moose/Role.pm +++ b/lib/Moose/Role.pm @@ -225,6 +225,8 @@ to cpan-RT. Stevan Little Estevan@iinteractive.comE +Christian Hansen + =head1 COPYRIGHT AND LICENSE Copyright 2006 by Infinity Interactive, Inc. diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 5c3cd69..68ed3ee 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -178,6 +178,8 @@ Moose::Util::TypeConstraints - Type constraint system for Moose coerce Num => from Str => via { 0+$_ }; + + enum RGBColors => qw(red green blue); =head1 DESCRIPTION diff --git a/t/070_more_attr_delegation.t b/t/070_more_attr_delegation.t index 29a5c9d..10d5e8c 100644 --- a/t/070_more_attr_delegation.t +++ b/t/070_more_attr_delegation.t @@ -70,7 +70,7 @@ use Test::Exception; has child_a => ( is => "ro", default => sub { ChildA->new }, - handles => all_methods, + handles => qr/.*/, ); } "all_methods requires explicit isa"; @@ -79,7 +79,7 @@ use Test::Exception; isa => "ChildA", is => "ro", default => sub { ChildA->new }, - handles => all_methods, + handles => qr/.*/, ); } "allow all_methods with explicit isa";