From: Stevan Little Date: Fri, 7 Apr 2006 17:08:58 +0000 (+0000) Subject: uploadin X-Git-Tag: 0_05~46 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e9ec68d692832824d0fc259df992ca1689538b53;p=gitmo%2FMoose.git uploadin --- diff --git a/Changes b/Changes index 9c9057f..b651184 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,31 @@ Revision history for Perl extension Moose 0.04 + * Moose::Cookbook + - added new Role recipe + + * Moose + - added 'with' keyword for Role support + - added test and docs for this + - fixed subtype quoting bug + - added test for this + + * Moose::Role + - Roles for Moose + - added test and docs + + * Moose::Meta::Role + - the meta role to support Moose::Role + - added tests and docs + + * Moose::Meta::Class + - moved a number of things from Moose.pm + to here, they should have been here + in the first place + + * Moose::Meta::Attribute + - moved the attribute option macros here + instead of putting them in Moose.pm 0.03 Thurs. March 30, 2006 * Moose::Cookbook diff --git a/MANIFEST b/MANIFEST index 98e5ca3..6081947 100644 --- a/MANIFEST +++ b/MANIFEST @@ -46,6 +46,7 @@ t/053_util_find_type_constraint.t t/054_util_type_coercion.t t/055_util_type_reloading.t t/056_util_more_type_coercion.t +t/100_subtype_quote_bug.t t/pod.t t/pod_coverage.t t/lib/Bar.pm diff --git a/lib/Moose.pm b/lib/Moose.pm index 260db75..f2dc314 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -33,7 +33,7 @@ sub import { # make a subtype for each Moose class subtype $pkg - => as Object + => as 'Object' => where { $_->isa($pkg) }; my $meta; @@ -259,6 +259,10 @@ actually Ces onto the class's C<@ISA>, whereas C will replace it. This is important to ensure that classes which do not have superclasses properly inherit from L. +=item B + +This will apply a given C<$role> to the local class. + =item B This will install an attribute of a given C<$name> into the current class. diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index d32abf1..5277d44 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -129,6 +129,12 @@ you are doing. This method makes sure to handle the moose weak-ref, type-constraint and type coercion features. +=item B + +This accomidates Moose::Meta::Role::Method instances, which are +aliased, instead of added, but still need to be counted as valid +methods. + =item B =item B diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index b25a5b5..0a0df2a 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -87,23 +87,23 @@ sub via (&) { $_[0] } # define some basic types -type Any => where { 1 }; +type 'Any' => where { 1 }; -type Value => where { !ref($_) }; -type Ref => where { ref($_) }; +type 'Value' => where { !ref($_) }; +type 'Ref' => where { ref($_) }; -subtype Int => as Value => where { Scalar::Util::looks_like_number($_) }; -subtype Str => as Value => where { !Scalar::Util::looks_like_number($_) }; +subtype 'Int' => as 'Value' => where { Scalar::Util::looks_like_number($_) }; +subtype 'Str' => as 'Value' => where { !Scalar::Util::looks_like_number($_) }; -subtype ScalarRef => as Ref => where { ref($_) eq 'SCALAR' }; -subtype ArrayRef => as Ref => where { ref($_) eq 'ARRAY' }; -subtype HashRef => as Ref => where { ref($_) eq 'HASH' }; -subtype CodeRef => as Ref => where { ref($_) eq 'CODE' }; -subtype RegexpRef => as Ref => where { ref($_) eq 'Regexp' }; +subtype 'ScalarRef' => as 'Ref' => where { ref($_) eq 'SCALAR' }; +subtype 'ArrayRef' => as 'Ref' => where { ref($_) eq 'ARRAY' }; +subtype 'HashRef' => as 'Ref' => where { ref($_) eq 'HASH' }; +subtype 'CodeRef' => as 'Ref' => where { ref($_) eq 'CODE' }; +subtype 'RegexpRef' => as 'Ref' => where { ref($_) eq 'Regexp' }; # NOTE: # blessed(qr/.../) returns true,.. how odd -subtype Object => as Ref => where { blessed($_) && blessed($_) ne 'Regexp' }; +subtype 'Object' => as 'Ref' => where { blessed($_) && blessed($_) ne 'Regexp' }; 1; diff --git a/t/100_subtype_quote_bug.t b/t/100_subtype_quote_bug.t new file mode 100644 index 0000000..f01d168 --- /dev/null +++ b/t/100_subtype_quote_bug.t @@ -0,0 +1,31 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 1; + +=pod + +This is a test for a bug found by Purge on #moose: +The code: + + subtype Stuff + => as Object + => where { ... } + +will break if the Object:: namespace exists. So the +solution is to quote 'Object', like so: + + subtype Stuff + => as 'Object' + => where { ... } + +Moose 0.03 did this, now it doesn't, so all should +be well from now on. + +=cut + +{ package Object::Test; } + +use_ok('Moose');