From: Shawn M Moore <sartak@gmail.com>
Date: Tue, 10 Jun 2008 02:14:14 +0000 (+0000)
Subject: Little nits
X-Git-Tag: 0.04~71
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fb706f5c1e60ddafe873717be7209066d47b8998;p=gitmo%2FMouse.git

Little nits
---

diff --git a/lib/Mouse/Attribute.pm b/lib/Mouse/Attribute.pm
index 0bc6a20..dd4a7ae 100644
--- a/lib/Mouse/Attribute.pm
+++ b/lib/Mouse/Attribute.pm
@@ -302,5 +302,15 @@ Creates a new code reference for the attribute's clearer.
 
 Creates a new code reference for each of the attribute's handles methods.
 
+=head2 find_type_constraint -> CODE
+
+Returns a code reference which can be used to check that a given value passes
+this attribute's type constraint;
+
+=head2 verify_type_constraint Item -> 1 | ERROR
+
+Checks that the given value passes this attribute's type constraint. Returns 1
+on success, otherwise C<confess>es.
+
 =cut
 
diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm
index dcb8590..e870e78 100644
--- a/lib/Mouse/Object.pm
+++ b/lib/Mouse/Object.pm
@@ -18,9 +18,8 @@ sub new {
 
         if (!exists($args{$key})) {
             if ($attribute->has_default || $attribute->has_builder) {
-                my $default = $attribute->default;
-
                 unless ($attribute->is_lazy) {
+                    my $default = $attribute->default;
                     my $builder = $attribute->builder;
                     my $value = $attribute->has_builder
                               ? $instance->$builder
diff --git a/t/025-more-isa.t b/t/025-more-isa.t
index 213fba8..e68e0ec 100644
--- a/t/025-more-isa.t
+++ b/t/025-more-isa.t
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 9;
+use Test::More tests => 10;
 use Test::Exception;
 
 do {
diff --git a/t/101-meta-attribute.t b/t/101-meta-attribute.t
index 454b609..ecb1eb1 100644
--- a/t/101-meta-attribute.t
+++ b/t/101-meta-attribute.t
@@ -29,4 +29,4 @@ is($attr->class, 'Class', 'attached class');
 is($attr->predicate, 'has_pawn', 'predicate');
 is($attr->clearer, 'clear_pawn', 'clearer');
 is(ref($attr->default), 'CODE', 'default is a coderef');
-
+ok($attr->verify_type_constraint(1), 'verify_type_constraint works even without isa');