r270@brr: dpavlin | 2007-11-25 21:14:10 +0100
[perl-cwmp.git] / lib / CWMP / Store / YAML.pm
1 # Dobrica Pavlinusic, <dpavlin@rot13.org> 10/26/07 21:37:12 CEST
2 package CWMP::Store::YAML;
3
4 use strict;
5 use warnings;
6
7 use CWMP::Store::HASH;
8 use base qw/CWMP::Store::HASH/;
9
10 use YAML::Syck;
11
12 =head1 NAME
13
14 CWMP::Store::YAML - use YAML as storage
15
16 =cut
17
18 my $full_path;
19
20 sub full_path {
21         my ( $self, $path ) = @_;
22         $full_path = "$path/yaml";
23         warn "## full_path: $full_path" if $debug;
24         return $full_path;
25 }
26
27 sub file {
28         my ( $self, $uid ) = @_;
29         my $file = "$full_path/$uid" . $self->extension;
30         warn "## file -> $file" if $debug;
31         return $file;
32 }
33
34 sub save_hash {
35         my ( $self, $file, $hash ) = @_;
36         DumpFile( $file, $hash );
37 }
38
39 sub load_hash {
40         my ( $self, $file ) = @_;
41         LoadFile( $file );
42 }
43
44 sub extension { '.yml' };
45
46 1;