adding support for Deferred
[gitmo/MooseX-Storage.git] / lib / MooseX / Storage / Util.pm
index e13ea97..0096b0b 100644 (file)
@@ -2,8 +2,9 @@ package MooseX::Storage::Util;
 use Moose qw(confess blessed);
 
 use MooseX::Storage::Engine ();
+use utf8 ();
 
-our $VERSION   = '0.01';
+our $VERSION   = '0.03';
 our $AUTHORITY = 'cpan:STEVAN';
 
 sub peek {
@@ -32,7 +33,10 @@ sub _inflate_json {
     my ($class, $json) = @_;
     
     require JSON::Any;
-    JSON::Any->import;
+    eval { JSON::Any->import };
+    confess "Could not load JSON module because : $@" if $@; 
+    
+    utf8::encode($json) if utf8::is_utf8($json);    
     
     my $data = eval { JSON::Any->jsonToObj($json) };
     if ($@) {
@@ -46,7 +50,8 @@ sub _inflate_yaml {
     my ($class, $yaml) = @_;
     
     require Best; 
-    Best->import([[ qw[YAML::Syck YAML] ]]);    
+    eval { Best->import([[ qw[YAML::Syck YAML] ]]) };
+    confess "Could not load YAML module because : $@" if $@; 
     
     my $inflater = Best->which('YAML::Syck')->can('Load');
     
@@ -137,7 +142,7 @@ Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2007 by Infinity Interactive, Inc.
+Copyright 2007-2008 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>