- added the ClassName type constraint, this checks for strings
which will respond true to ->isa(UNIVERSAL).
- added tests and docs for this
+ - subtyping just in name now works correctly by making the
+ default for where be { 1 }
+ - added test for this
* Moose::Meta::Method::Accessor
- coerce and lazy now work together correctly, thanks to
- tests added for this
- fix reader presedence bug in Moose::Meta::Attribute + tests
+ * Moose::Object
+ - Foo->new(undef) now gets ignored, it is assumed you meant to pass
+ a HASH-ref and missed. This produces better error messages then
+ having it die cause undef is not a HASH.
+ - added tests for this
+
0.21 Thursday, May 2nd, 2007
* Moose
- added SUPER_SLOT and INNER_SLOT class hashes to support unimport
t/056_util_more_type_coercion.t
t/057_union_types.t
t/058_union_types_and_coercions.t
+t/059_misc_type_tests.t
t/060_moose_for_meta.t
t/070_more_attr_delegation.t
t/071_misc_attribute_tests.t
t/105_module_refresh_compat.t
t/106_handles_foreign_class_bug.t
t/107_custom_attr_meta_with_roles.t
+t/108_custom_attr_meta_as_role.t
+t/109_reader_precedence_bug.t
+t/110_new_w_undef.t
t/201_example.t
t/202_example_Moose_POOP.t
t/203_example.t
t/204_example_w_DCS.t
t/205_example_w_TestDeep.t
+t/206_example_Protomoose.t
t/300_immutable_moose.t
t/pod.t
t/pod_coverage.t
use Carp 'confess';
-our $VERSION = '0.08';
+our $VERSION = '0.09';
our $AUTHORITY = 'cpan:STEVAN';
sub new {
my $class = shift;
my %params;
if (scalar @_ == 1) {
- (ref($_[0]) eq 'HASH')
- || confess "Single parameters to new() must be a HASH ref";
- %params = %{$_[0]};
+ if (defined $_[0]) {
+ (ref($_[0]) eq 'HASH')
+ || confess "Single parameters to new() must be a HASH ref";
+ %params = %{$_[0]};
+ }
}
else {
%params = @_;
use warnings;
use Carp 'confess';
-use Scalar::Util 'blessed';
+use Scalar::Util 'blessed', 'reftype';
use B 'svref_2object';
use Sub::Exporter;
sub _create_type_constraint ($$$;$$) {
my $name = shift;
my $parent = shift;
- my $check = shift;;
+ my $check = shift || sub { 1 };
my ($message, $optimized);
for (@_) {
}
sub subtype ($$;$$$) {
- unshift @_ => undef if scalar @_ <= 2;
+ # NOTE:
+ # this adds an undef for the name
+ # if this is an anon-subtype:
+ # subtype(Num => where { $_ % 2 == 0 }) # anon 'even' subtype
+ # but if the last arg is not a code
+ # ref then it is a subtype alias:
+ # subtype(MyNumbers => as Num); # now MyNumbers is the same as Num
+ # ... yeah I know it's ugly code
+ # - SL
+ unshift @_ => undef if scalar @_ <= 2 && (reftype($_[1]) || '') eq 'CODE';
goto &_create_type_constraint;
}
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+use Test::Exception;
+
+BEGIN {
+ use_ok('Moose::Util::TypeConstraints');
+}
+
+# subtype 'aliasing' ...
+
+lives_ok {
+ subtype 'Numb3rs' => as 'Num';
+} '... create bare subtype fine';
+
+my $numb3rs = find_type_constraint('Numb3rs');
+isa_ok($numb3rs, 'Moose::Meta::TypeConstraint');
\ No newline at end of file
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Moose;
+
+use Test::More tests => 1;
+use Test::Exception;
+
+{
+ package Foo;
+ use Moose;
+ has 'foo' => ( is => 'ro' );
+}
+
+lives_ok {
+ Foo->new(undef);
+} '... passing in undef just gets ignored';
+
+
+
+