Subject: | Add _init function to be compatible with URI |
The URI package automatically detects URI::* modules installed on a
system and will try to use them if the * matches the scheme. The URI
package will then called a method called _init on your package and fail.
I recommend you add:
sub _init {
my ($class, $uri, $scheme) = @_;
$uri = "$scheme:$uri" unless $uri =~ m{\A $scheme}x;
return $class->new(telephone_uri => $uri);
}
This will allow people who have URI::tel installed to call
URI->new('tel:+1-201-555-0123') and automatically get back an instance
of your package instead of their code dying. Here is also a
corresponding test:
isa_ok(URI->new('tel:+1-201-555-0123'), 'URI::tel');