Created
July 6, 2009 18:53
-
-
Save EvanCarroll/141610 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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