Commit | Line | Data |
6d01d9c1 |
1 | package DBIx::Class::Fixtures::External::File; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use File::Spec::Functions 'catfile'; |
7 | |
8 | sub _load { |
9 | my ($class, $path) = @_; |
10 | open(my $fh, '<', $path) |
11 | || die "can't open $path: $!"; |
12 | local $/ = undef; |
13 | my $content = <$fh>; |
14 | } |
15 | |
16 | sub _save { |
17 | my ($class, $path, $content) = @_; |
18 | open (my $fh, '>', $path) |
19 | || die "can't open $path: $!"; |
20 | print $fh $content; |
21 | close($fh); |
22 | } |
23 | |
24 | sub fetch { |
25 | my ($class, $key, $args) = @_; |
26 | my $path = catfile($args->{path}, $key); |
27 | return my $fetched = $class->_load($path); |
28 | } |
29 | |
30 | sub write { |
31 | my ($class, $key, $content, $args) = @_; |
32 | my $path = catfile($args->{path}, $key); |
33 | $class->_save($path, $content); |
34 | } |
35 | |
36 | 1; |