Created
May 2, 2013 15:24
-
-
Save patch/5502982 to your computer and use it in GitHub Desktop.
Coerce Moose attribute from Num to Math::BigFloat (untested).
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
use Moose; | |
use Moose::Util::TypeConstraints; | |
use Math::BigFloat; | |
subtype 'BigFloat', | |
as class_type('Math::BigFloat'); | |
coerce 'BigFloat', | |
from 'Num', | |
via { Math::BigFloat->new($_) }; | |
has 'amount' => ( | |
is => 'rw', | |
isa => 'BigFloat', | |
coerce => 1, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment