1. Diab Jerius
  2. Hg::Lib

Commits

Diab Jerius  committed c3e0c13

improve default, coercion and type constraint code to match newer Moo & Types

  • Participants
  • Parent commits 6a3ccef
  • Branches default

Comments (0)

Files changed (1)

File lib/Hg/Lib/Server/Pipe.pm

View file
  • Ignore whitespace
     *WUNTRACED = $have_WUNTRACED ? \&POSIX::WUNTRACED : sub () { 0 };
 }
 
-sub forceArray {
-    sub { 'ARRAY' eq ref $_[0] ? $_[0] : [ $_[0] ] }
-}
-
+use constant forceArray =>
+    sub { 'ARRAY' eq ref $_[0] ? $_[0] : [ $_[0] ] };
 
 with 'MooX::Attributes::Shadow::Role';
 
 # path to hg executable
 has hg => (
     is      => 'ro',
-    default => sub { 'hg' },
+    default => 'hg',
     coerce  => forceArray,
-    isa     => sub {
-        is_Str( $_ )
-          or die( "'hg' attribute must be string\n" )
-          foreach @{ shift() };
-    },
+    isa     => ArrayRef[Str],
 );
 
 # arguments to hg
 has args => (
     is      => 'ro',
     coerce  => forceArray,
+    isa     => ArrayRef[Str],
     default => sub { [] },
 );
 
 has configs => (
     is      => 'ro',
     coerce  => forceArray,
+    isa     => ArrayRef[Str],
     default => sub { [] },
 );