Tie::IxHash coercion

[email protected] (William Bellamy Bellamy)
Newsgroups perl.moose
Message-ID <[email protected]>
Hi, 

So to clarify my previous email I currently have the code below but I cannot get the attribute 'reasons' coerced into a Tie::IxHash. Any insights would be most appreciated.

Many thanks

Bill



use Tie::IxHash;
use Moose;
use Moose::Util::TypeConstraints;

subtype 'IxHash' 
    => as 'HashRef' 
    => where { 
        ref $_ eq 'HASH' 
};

coerce 'IxHash'
=> from 'HashRef'
=> via { 
    tie (%$_,'Tie::IxHash') unless tied $_; return $_; 
    
};

no Moose::Util::TypeConstraints;

has 'reasons' => (
    is  => 'ro', 
    isa => 'IxHash',
    default => sub { {} },
    coerce => 1
);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.