Skip to content

Instantly share code, notes, and snippets.

@EvanCarroll
Created July 6, 2009 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvanCarroll/141610 to your computer and use it in GitHub Desktop.
Save EvanCarroll/141610 to your computer and use it in GitHub Desktop.
package DM::Model::Types::Overload;
use mro 'c3';
use overload;
use feature ':5.10';
sub unoverload {
die "$_[0] Not an object that is overloaded"
if !overload::Method( $_[0], '""' )
;
"$_[0]"; ## Stingify
}
use MooseX::Types::Moose ':all';
my @types;
BEGIN { @types = keys %{ MooseX::Types::Moose::type_storage() } };
use MooseX::Types -declare => [map "OL$_", @types];
foreach my $t ( @types ) {
## THIS WORKS
#coerce eval $t , from Object, via \&unoverload;
## THIS DOESNT
coerce __PACKAGE__->can( $t ) , from Object, via \&unoverload;
}
1;
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment