Subject: | Handles on ClassName attribute |
Handles should work on Classname attributes for things like Storable
FreezeThaw and YAML
Subject: | moose_attribute_classname_handles.t |
## ClassName should permit delegation based on class-functions
## As in the case of Storable/FreezeThaw and YAML, and Digest::*
package K;
use Storable;
package Class;
use Moose;
has 'foobar' => (
isa => 'ClassName'
, is => 'ro'
, handles => [qw/freeze thaw/]
);
package ClassS;
use Moose;
has 'foobar' => (
isa => 'ClassName'
, is => 'ro'
, handles => [qw/freeze thaw/]
, lazy => 1
, default => 'Storable'
);
package main;
use Test::More tests => 2;
eval {
Class->new({ foobar => 'Storable' })->freeze( [qw/foo bar abz/] );
};
unlike ( $@, qr/not a reference/, "Handles on ClassName" );
eval {
ClassS->new->freeze( [qw/foo bar abz/] );
};
ok ( ! defined $@, "Handles on ClassName (lazy)" );