delay loading all optional prereqs until runtime
[gitmo/MooseX-Storage.git] / lib / MooseX / Storage / Engine / IO / File.pm
index e080d4c..7756ac3 100644 (file)
@@ -1,8 +1,6 @@
 package MooseX::Storage::Engine::IO::File;
 use Moose;
 
-use IO::File;
-
 has 'file' => (
     is       => 'ro',
     isa      => 'Str',
@@ -11,6 +9,8 @@ has 'file' => (
 
 sub load {
     my ($self) = @_;
+
+    require IO::File;
     my $fh = IO::File->new($self->file, 'r')
         || confess "Unable to open file (" . $self->file . ") for loading : $!";
     return do { local $/; <$fh>; };
@@ -18,6 +18,8 @@ sub load {
 
 sub store {
     my ($self, $data) = @_;
+
+    require IO::File;
     my $fh = IO::File->new($self->file, 'w')
         || confess "Unable to open file (" . $self->file . ") for storing : $!";
     $fh->binmode(':utf8') if utf8::is_utf8($data);