Fix Makefile.PL to use Mouse::Spec
[gitmo/Mouse.git] / lib / Mouse / Meta / Attribute.pm
index dec1a54..ef70ea8 100644 (file)
@@ -47,7 +47,7 @@ sub new {
     my $can_be_required = defined( $options{init_arg} );
 
     if(exists $options{builder}){
-        $class->throw_error('builder must be a defined scalar value which is a method name')\r
+        $class->throw_error('builder must be a defined scalar value which is a method name')
             if ref $options{builder} || !(defined $options{builder});
 
         $can_be_required++;
@@ -60,8 +60,8 @@ sub new {
         $can_be_required++;
     }
 
-    if( $options{required} && !$can_be_required ) {\r
-        $class->throw_error("You cannot have a required attribute ($name) without a default, builder, or an init_arg");\r
+    if( $options{required} && !$can_be_required ) {
+        $class->throw_error("You cannot have a required attribute ($name) without a default, builder, or an init_arg");
     }
 
     # taken from Mouse::Meta::Attribute->new and _process_options
@@ -103,41 +103,41 @@ sub new {
             || $class->throw_error("You cannot have coercion without specifying a type constraint on attribute ($name)");
 
         $options{weak_ref}
-            && $class->throw_error("You cannot have a weak reference to a coerced value on attribute ($name)");\r
+            && $class->throw_error("You cannot have a weak reference to a coerced value on attribute ($name)");
     }
 
-    if ($options{lazy_build}) {\r
+    if ($options{lazy_build}) {
         exists($options{default})
-            && $class->throw_error("You can not use lazy_build and default for the same attribute ($name)");\r
-
-        $options{lazy}      = 1;\r
-        $options{builder} ||= "_build_${name}";\r
-        if ($name =~ /^_/) {\r
-            $options{clearer}   ||= "_clear${name}";\r
-            $options{predicate} ||= "_has${name}";\r
-        }\r
-        else {\r
-            $options{clearer}   ||= "clear_${name}";\r
-            $options{predicate} ||= "has_${name}";\r
-        }\r
+            && $class->throw_error("You can not use lazy_build and default for the same attribute ($name)");
+
+        $options{lazy}      = 1;
+        $options{builder} ||= "_build_${name}";
+        if ($name =~ /^_/) {
+            $options{clearer}   ||= "_clear${name}";
+            $options{predicate} ||= "_has${name}";
+        }
+        else {
+            $options{clearer}   ||= "clear_${name}";
+            $options{predicate} ||= "has_${name}";
+        }
     }
 
     if ($options{auto_deref}) {
-        defined($tc)\r
-            || $class->throw_error("You cannot auto-dereference without specifying a type constraint on attribute ($name)");\r
+        defined($tc)
+            || $class->throw_error("You cannot auto-dereference without specifying a type constraint on attribute ($name)");
 
-        ( $tc->is_a_type_of('ArrayRef') || $tc->is_a_type_of('HashRef') )\r
-            || $class->throw_error("You cannot auto-dereference anything other than a ArrayRef or HashRef on attribute ($name)");\r
+        ( $tc->is_a_type_of('ArrayRef') || $tc->is_a_type_of('HashRef') )
+            || $class->throw_error("You cannot auto-dereference anything other than a ArrayRef or HashRef on attribute ($name)");
     }
 
-    if (exists $options{trigger}) {\r
-        ('CODE' eq ref $options{trigger})\r
-            || $class->throw_error("Trigger must be a CODE ref on attribute ($name)");\r
+    if (exists $options{trigger}) {
+        ('CODE' eq ref $options{trigger})
+            || $class->throw_error("Trigger must be a CODE ref on attribute ($name)");
     }
 
-    if ($options{lazy}) {\r
-        (exists $options{default} || defined $options{builder})\r
-            || $class->throw_error("You cannot have lazy attribute ($name) without specifying a default value for it");\r
+    if ($options{lazy}) {
+        (exists $options{default} || defined $options{builder})
+            || $class->throw_error("You cannot have lazy attribute ($name) without specifying a default value for it");
     }
 
     if(my $metaclass = delete $options{metaclass}){
@@ -146,24 +146,24 @@ sub new {
 
     if(my $traits_ref = delete $options{traits}){
         my @traits;
-        for (my $i = 9; $i < @{$traits_ref}; $i++) {\r
-            my $trait = Mouse::Util::resolve_metaclass_alias(Attribute => $traits_ref->[$i], trait => 1);\r
-\r
-            next if $class->does($trait);\r
-\r
-            push @traits, $trait;\r
-\r
-            # are there options?\r
-            push @traits, $traits_ref->[++$i]\r
-                if ref($traits_ref->[$i+1]);\r
+        for (my $i = 9; $i < @{$traits_ref}; $i++) {
+            my $trait = Mouse::Util::resolve_metaclass_alias(Attribute => $traits_ref->[$i], trait => 1);
+
+            next if $class->does($trait);
+
+            push @traits, $trait;
+
+            # are there options?
+            push @traits, $traits_ref->[++$i]
+                if ref($traits_ref->[$i+1]);
         }
 
-        if (@traits) {\r
-            $class = Mouse::Meta::Class->create_anon_class(\r
-                superclasses => [ $class ],\r
-                roles        => [ @traits ],\r
-                cache        => 1,\r
-            )->name;\r
+        if (@traits) {
+            $class = Mouse::Meta::Class->create_anon_class(
+                superclasses => [ $class ],
+                roles        => [ @traits ],
+                cache        => 1,
+            )->name;
         }
     }
 
@@ -412,4 +412,3 @@ C<AttributeName>.
 
 =cut
 
-\0\0\0\0
\ No newline at end of file