Skip to content

Commit

Permalink
Added an example of a complex unit, and lo and behold, found and fixe…
Browse files Browse the repository at this point in the history
…d a bug
  • Loading branch information
jberger committed Dec 9, 2011
1 parent 976f870 commit 6763ed2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions ex/example.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package MyTest;

use lib 'lib';
use Moose;
use MooseX::Types::NumUnit qw/num_of_unit/;

#$MooseX::Types::NumUnit::Verbose = 1;

has 'speed' => ( isa => num_of_unit('ft / hour'), is => 'rw', required => 1 );

no Moose;
__PACKAGE__->meta->make_immutable;

my $test = MyTest->new( speed => '2 m / s' );

print $test->speed, "\n";

2 changes: 1 addition & 1 deletion lib/MooseX/Types/NumUnit.pm
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ sub convert {
$requested_unit = $base_unit;
}

my $req_str = $requested_unit->name . " [" . $requested_unit->expanded . "]";
my $req_str = ($requested_unit->name || $requested_unit->def) . " [" . $requested_unit->expanded . "]";

my $conv_error = 0;
{
Expand Down

0 comments on commit 6763ed2

Please sign in to comment.