Rename has_inlined_type_constraint to can_be_inlined
Dave Rolsky [Thu, 21 Apr 2011 18:44:24 +0000 (13:44 -0500)]
lib/Moose/Meta/Attribute.pm
lib/Moose/Meta/Method/Accessor/Native/Collection.pm
lib/Moose/Meta/TypeConstraint.pm
lib/Moose/Meta/TypeConstraint/Parameterized.pm
lib/Moose/Meta/TypeConstraint/Union.pm
t/type_constraints/inlining.t
t/type_constraints/util_std_type_constraints.t

index eb4bfd6..6b95ee1 100644 (file)
@@ -639,7 +639,7 @@ sub _inline_check_constraint {
 
     my $attr_name = quotemeta($self->name);
 
-    if ( $self->type_constraint->has_inlined_type_constraint ) {
+    if ( $self->type_constraint->can_be_inlined ) {
         return (
             'if (! (' . $self->type_constraint->_inline_check($value) . ')) {',
                 $self->_inline_throw_error(
index 377bc13..c4ce898 100644 (file)
@@ -98,7 +98,7 @@ sub _inline_check_member_constraint {
     my $attr_name = $self->associated_attribute->name;
 
     my $check
-        = $self->_tc_member_type->has_inlined_type_constraint
+        = $self->_tc_member_type->can_be_inlined
         ? '! (' . $self->_tc_member_type->_inline_check('$_') . ')'
         : ' !$member_tc->($_) ';
 
index ab6e6e7..2d5bda1 100644 (file)
@@ -135,11 +135,11 @@ sub validate {
     }
 }
 
-sub has_inlined_type_constraint {
+sub can_be_inlined {
     my $self = shift;
 
     if ( $self->has_parent && $self->constraint == $null_constraint ) {
-        return $self->parent->has_inlined_type_constraint;
+        return $self->parent->can_be_inlined;
     }
 
     return $self->_has_inlined_type_constraint;
@@ -148,7 +148,7 @@ sub has_inlined_type_constraint {
 sub _inline_check {
     my $self = shift;
 
-    unless ( $self->has_inlined_type_constraint ) {
+    unless ( $self->can_be_inlined ) {
         require Moose;
         Moose->throw_error( 'Cannot inline a type constraint check for ' . $self->name );
     }
@@ -256,7 +256,7 @@ sub _actually_compile_type_constraint {
     return $self->_compile_hand_optimized_type_constraint
         if $self->has_hand_optimized_type_constraint;
 
-    if ( $self->has_inlined_type_constraint ) {
+    if ( $self->can_be_inlined ) {
         return eval_closure(
             source      => 'sub { ' . $self->_inline_check('$_[0]') . ' }',
             environment => $self->inline_environment,
index 576affa..09c2473 100644 (file)
@@ -63,19 +63,19 @@ sub compile_type_constraint {
           . $self->parent->name . " doesn't subtype or coerce from a parameterizable type.");
 }
 
-sub has_inlined_type_constraint {
+sub can_be_inlined {
     my $self = shift;
 
     return
            $self->has_parameterized_from
         && $self->parameterized_from->has_inline_generator
-        && $self->type_parameter->has_inlined_type_constraint;
+        && $self->type_parameter->can_be_inlined;
 }
 
 sub _inline_check {
     my $self = shift;
 
-    return unless $self->has_inlined_type_constraint;
+    return unless $self->can_be_inlined;
 
     return $self->parameterized_from->generate_inline_for( $self->type_parameter, @_ );
 }
index 8b695e0..feb4697 100644 (file)
@@ -71,11 +71,10 @@ sub _actually_compile_type_constraint {
     };
 }
 
-sub has_inlined_type_constraint {
+sub can_be_inlined {
     my $self = shift;
 
-    return all { $_->has_inlined_type_constraint }
-        @{ $self->type_constraints };
+    return all { $_->can_be_inlined } @{ $self->type_constraints };
 }
 
 sub _inline_check {
index b8b4449..c5417ca 100644 (file)
@@ -24,8 +24,8 @@ my $not_inlinable = find_type_constraint('NotInlinable');
 
 {
     ok(
-        $inlinable->has_inlined_type_constraint,
-        'Inlinable returns true for has_inlined_type_constraint'
+        $inlinable->can_be_inlined,
+        'Inlinable returns true for can_be_inlined'
     );
 
     is(
@@ -35,8 +35,8 @@ my $not_inlinable = find_type_constraint('NotInlinable');
     );
 
     ok(
-        !$not_inlinable->has_inlined_type_constraint,
-        'NotInlinable returns false for has_inlined_type_constraint'
+        !$not_inlinable->can_be_inlined,
+        'NotInlinable returns false for can_be_inlined'
     );
 
     like(
@@ -51,8 +51,8 @@ my $not_inlinable = find_type_constraint('NotInlinable');
         'ArrayRef[Inlinable]');
 
     ok(
-        $aofi->has_inlined_type_constraint,
-        'ArrayRef[Inlinable] returns true for has_inlined_type_constraint'
+        $aofi->can_be_inlined,
+        'ArrayRef[Inlinable] returns true for can_be_inlined'
     );
 
     is(
@@ -65,8 +65,8 @@ my $not_inlinable = find_type_constraint('NotInlinable');
         'ArrayRef[NotInlinable]');
 
     ok(
-        !$aofni->has_inlined_type_constraint,
-        'ArrayRef[NotInlinable] returns false for has_inlined_type_constraint'
+        !$aofni->can_be_inlined,
+        'ArrayRef[NotInlinable] returns false for can_be_inlined'
     );
 }
 
@@ -80,8 +80,8 @@ subtype 'ArrayOfNotInlinable',
         'ArrayOfInlinable');
 
     ok(
-        $aofi->has_inlined_type_constraint,
-        'ArrayOfInlinable returns true for has_inlined_type_constraint'
+        $aofi->can_be_inlined,
+        'ArrayOfInlinable returns true for can_be_inlined'
     );
 
     is(
@@ -94,8 +94,8 @@ subtype 'ArrayOfNotInlinable',
         'ArrayOfNotInlinable');
 
     ok(
-        !$aofni->has_inlined_type_constraint,
-        'ArrayOfNotInlinable returns false for has_inlined_type_constraint'
+        !$aofni->can_be_inlined,
+        'ArrayOfNotInlinable returns false for can_be_inlined'
     );
 }
 
@@ -104,8 +104,8 @@ subtype 'ArrayOfNotInlinable',
         'HashRef[ArrayRef[Inlinable]]');
 
     ok(
-        $hoaofi->has_inlined_type_constraint,
-        'HashRef[ArrayRef[Inlinable]] returns true for has_inlined_type_constraint'
+        $hoaofi->can_be_inlined,
+        'HashRef[ArrayRef[Inlinable]] returns true for can_be_inlined'
     );
 
     is(
@@ -118,8 +118,8 @@ subtype 'ArrayOfNotInlinable',
         'HashRef[ArrayRef[NotInlinable]]');
 
     ok(
-        !$hoaofni->has_inlined_type_constraint,
-        'HashRef[ArrayRef[NotInlinable]] returns false for has_inlined_type_constraint'
+        !$hoaofni->can_be_inlined,
+        'HashRef[ArrayRef[NotInlinable]] returns false for can_be_inlined'
     );
 }
 
@@ -128,8 +128,8 @@ subtype 'ArrayOfNotInlinable',
         'Inlinable | Object');
 
     ok(
-        $iunion->has_inlined_type_constraint,
-        'Inlinable | Object returns true for has_inlined_type_constraint'
+        $iunion->can_be_inlined,
+        'Inlinable | Object returns true for can_be_inlined'
     );
 
     is(
@@ -142,8 +142,8 @@ subtype 'ArrayOfNotInlinable',
         'NotInlinable | Object');
 
     ok(
-        !$niunion->has_inlined_type_constraint,
-        'NotInlinable | Object returns false for has_inlined_type_constraint'
+        !$niunion->can_be_inlined,
+        'NotInlinable | Object returns false for can_be_inlined'
     );
 }
 
@@ -152,8 +152,8 @@ subtype 'ArrayOfNotInlinable',
         'Object | Inlinable');
 
     ok(
-        $iunion->has_inlined_type_constraint,
-        'Object | Inlinable returns true for has_inlined_type_constraint'
+        $iunion->can_be_inlined,
+        'Object | Inlinable returns true for can_be_inlined'
     );
 
     is(
@@ -166,8 +166,8 @@ subtype 'ArrayOfNotInlinable',
         'Object | NotInlinable');
 
     ok(
-        !$niunion->has_inlined_type_constraint,
-        'Object | NotInlinable returns false for has_inlined_type_constraint'
+        !$niunion->can_be_inlined,
+        'Object | NotInlinable returns false for can_be_inlined'
     );
 }
 
@@ -176,8 +176,8 @@ subtype 'ArrayOfNotInlinable',
         'Object | Inlinable | CodeRef');
 
     ok(
-        $iunion->has_inlined_type_constraint,
-        'Object | Inlinable | CodeRef returns true for has_inlined_type_constraint'
+        $iunion->can_be_inlined,
+        'Object | Inlinable | CodeRef returns true for can_be_inlined'
     );
 
     is(
@@ -190,8 +190,8 @@ subtype 'ArrayOfNotInlinable',
         'Object | NotInlinable | CodeRef');
 
     ok(
-        !$niunion->has_inlined_type_constraint,
-        'Object | NotInlinable | CodeRef returns false for has_inlined_type_constraint'
+        !$niunion->can_be_inlined,
+        'Object | NotInlinable | CodeRef returns false for can_be_inlined'
     );
 }
 
index 12ca75a..d0855d3 100644 (file)
@@ -1011,7 +1011,7 @@ sub test_constraint {
         : $type->_compile_type( $type->constraint );
 
     my $inlined;
-    if ( $type->has_inlined_type_constraint ) {
+    if ( $type->can_be_inlined ) {
         $inlined = eval_closure(
             source      => 'sub { ( ' . $type->_inline_check('$_[0]') . ' ) }',
             environment => $type->inline_environment,