X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FJSON%2FMaybeXS.pm;h=cd2018315d81978bf075117561ff3f2aea525fc0;hb=06551ef5e477d0c227b70b0bd5be900a449175b6;hp=2f90001b8b730de05f0890ca51c564839e9cce66;hpb=4f5011ee0855b7bf1936ecb1cfafb5941215c234;p=p5sagit%2FJSON-MaybeXS.git diff --git a/lib/JSON/MaybeXS.pm b/lib/JSON/MaybeXS.pm index 2f90001..cd20183 100644 --- a/lib/JSON/MaybeXS.pm +++ b/lib/JSON/MaybeXS.pm @@ -223,6 +223,27 @@ To include JSON-aware booleans (C, C) in your data, just do: my $true = JSON->true; my $false = JSON->false; +=head1 CAVEATS + +The C method in this module is technically a factory, not a +constructor, because the objects it returns will I be blessed into the +C class. + +If you are using an object returned by this module as a Moo(se) attribute, +this type constraint code: + + is 'json' => ( isa => 'JSON::MaybeXS' ); + +will I do what you expect. Instead, either rely on the C class +constant described above, as so: + + is 'json' => ( isa => JSON::MaybeXS::JSON() ); + +Alternatively, you can use duck typing: + + use Moose::Util::TypeConstraints; + is 'json' => ( isa => Object , duck_type([qw/ encode decode /])); + =head1 AUTHOR mst - Matt S. Trout (cpan:MSTROUT)