/[Frey]/trunk/lib/Frey/Storage.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Storage.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 152 by dpavlin, Wed Jul 16 23:04:22 2008 UTC revision 153 by dpavlin, Wed Jul 16 23:21:19 2008 UTC
# Line 1  Line 1 
1  package Frey::Storage;  package Frey::Storage;
2  use Moose::Role;  use Moose::Role;
3    
4  use YAML::Syck;  #use YAML::Syck; # XXX doesn't play nice with Continuity
5    use YAML qw/LoadFile DumpFile/;
6    
7  =head2 store  =head2 store
8    
# Line 31  sub store { Line 32  sub store {
32  sub load {  sub load {
33          my ( $self, $filename ) = @_;          my ( $self, $filename ) = @_;
34          $filename .= '.yml';          $filename .= '.yml';
35            return if ! -e $filename;
36          $self->storage_timestamp->{ $filename } = _path_time( $filename );          $self->storage_timestamp->{ $filename } = _path_time( $filename );
37          LoadFile( $filename );          LoadFile( $filename );
38  }  }
# Line 39  sub load { Line 41  sub load {
41    
42  Reload file if on-disk copy have changed  Reload file if on-disk copy have changed
43    
44    $o->reload( 'filename.yml', \$data );    my $new_data = $o->reload( 'filename.yml' );
45    
46  =cut  =cut
47    
# Line 48  sub _path_time { Line 50  sub _path_time {
50  }  }
51    
52  sub reload {  sub reload {
53          my ( $self, $filename, $data ) = @_;          my ( $self, $filename ) = @_;
54          my $path = $filename . '.yml';          my $path = $filename . '.yml';
55          return if ( $self->storage_timestamp->{ $path } == _path_time( $path ) );          return if ( $self->storage_timestamp->{ $path } == _path_time( $path ) );
56          warn "# reload $filename" if $self->debug;          warn "# reload $filename" if $self->debug;
57          $$data = $self->load( $filename );          $self->load( $filename );
         $data;  
58  }  }
59    
60  1;  1;

Legend:
Removed from v.152  
changed lines
  Added in v.153

  ViewVC Help
Powered by ViewVC 1.1.26