| 1 | package Image::Delivery::Provider::IOHandle; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use UNIVERSAL 'isa'; | ||
| 5 | use base 'Image::Delivery::Provider::Scalar'; | ||
| 6 | use File::Slurp (); | ||
| 7 | |||
| 8 | use vars qw{$VERSION}; | ||
| 9 | BEGIN { | ||
| 10 | $VERSION = '0.14'; | ||
| 11 | } | ||
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | ##################################################################### | ||
| 18 | # Constructor | ||
| 19 | |||
| 20 | sub new { | ||
| 21 | my $class = shift; | ||
| 22 | my $handle = isa(ref $_[0], 'IO::Handle') ? shift : return undef; | ||
| 23 | |||
| 24 | # Slurp in the image | ||
| 25 | my $image = File::Slurp::read_file( $handle, scalar_ref => 1 ); | ||
| 26 | return undef unless ref $image eq 'SCALAR'; | ||
| 27 | |||
| 28 | # Hand off to our parent | ||
| 29 | $class->SUPER::new( $image, @_ ); | ||
| 30 | } | ||
| 31 | |||
| 32 | 1; |