Hi everyone!
Since I'm new here i just want to say hello to everyone :-)
...and the question is:
Do you have any ideas why abspath attribute is not coercing in the code
below (via code block in Path subtype is never used)?
package Test;
use Cwd qw/abs_path/;
use Moose;
use Moose::Util::TypeConstraints;
subtype 'Path' => as 'Str';
coerce 'Path' => from 'Str' => via { abs_path $_ };
subtype 'Path2' => as 'ArrayRef';
coerce 'Path2' => from 'Str' => via { [ abs_path $_ ] };
has 'abspath' => (
is => 'ro',
isa => 'Path',
coerce => 1
);
has 'abspath2' => (
is => 'ro',
isa => 'Path2',
coerce => 1,
);
my $t = Test->new(
abspath => "/home/jabbas/../",
abspath2 => "/home/jabbas/../"
);
say $t->abspath; # prints /home/jabbas/../
say @{$t->abspath2}; # prints /home
--
Greg Dzięgielewski
http://jabbas.pl