moose/MooseX-Storage — pull request #1 by tobyink (2013-09-13 08:04:08+00:00)
Title: Stringify type constraint objects more consistently.

MooseX::Storage::Engine needs to store type constraints as hash keys. In some places it does this using:

$hash{ $constraint }

And in others it uses:

$hash{ $constraint->name }

With a Moose::Meta::TypeConstraint object, the two have the same effect. However, for Type::Tiny and Specio, they can return different things.

In the case of Type::Tiny, anonymous type constraints are a lot more common than they are in Moose, so `name` often returns "__ANON__" even if the stringified type constraint ("" overload) is a more helpful string.

In the case of Specio::Constraint::Simple, there is no "" overload, so the stringification is something like "Specio::Constraint::Simple=HASH(0x12345678)", even if the name method returns something more helpful.

This pull request ensures that stringification is performed more consistently, *always* using object stringification to generate the hash keys, and not the `name` method (though the `name` method is still used in some other places, such as error messages). It adds test cases using MooseX::Storage with Specio and with Type::Tiny, though these are skipped (Test::Requires) if the relevant modules are not available.

Ultimately it might be a good idea to switch from using stringified type names as hash keys, and move to using a fieldhash, but this seems like a reasonable interim solution.

I've also bundled another fix for Specio, avoiding calling the `is_subtype_of` method on Specio type constraints (which don't have any such method).