This file is indexed.

/usr/share/perl5/Spoon/ContentObject.pm is in libspoon-perl 0.24-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package Spoon::ContentObject;
use Spoon::DataObject -Base;

stub 'content';
stub 'metadata';
const is_readable => 1;
const is_writable => 1;

sub force {
    if (@_) {
        $self->{force} = shift;
        return $self;
    }
    $self->{force} ||= 0;
}

sub database_directory {
    join '/', $self->hub->config->database_directory, $self->class_id; 
}

sub file_path {
    join '/', $self->database_directory, $self->id;
}

sub exists {
    -e $self->file_path;
}

sub deleted {
    -z $self->file_path;
}

sub active {
    return $self->exists && not $self->deleted;
}

sub assert_readable {
    if (not $self->is_readable) {
        my $id = $self->id;
        die "$id is not readable";
    }
}

sub assert_writable {
    if (not $self->is_writable) {
        my $id = $self->id;
        die "$id is not writable";
    }
}

sub load {
    $self->load_content;
    $self->load_metadata;
    return $self;
}

sub load_content {
    $self->assert_readable;
    my $content = $self->active
    ? io($self->file_path)->utf8->all
    : '';
    $self->content($content);
    return $self;
}

sub load_metadata {
    my $metadata = $self->{metadata}
      or die "No metadata object in content object";
    $metadata->load;
    return $self;
}

sub store {
    $self->assert_writable;
    $self->store_content or return;
    $self->store_metadata;
    return if $self->force;
    return $self;
}

sub store_content {
    my $content = $self->content;
    if ($content) {
        $content =~ s/\r//g;
        $content =~ s/\n*\z/\n/;
    }
    my $file = io->file($self->file_path)->utf8;
    unless ($self->force) {
        return if $file->exists and 
                  $content eq $file->all;
    }
    $file->print($content);
    return $self;
}

sub store_metadata {
    my $metadata = $self->{metadata}
      or die "No metadata for content object";
    $metadata->store;
    return $self;
}

__DATA__

=head1 NAME 

Spoon::ContentObject - Spoon Content Object Base Class

=head1 SYNOPSIS

=head1 DESCRIPTION

=head1 AUTHOR

Brian Ingerson <INGY@cpan.org>

=head1 COPYRIGHT

Copyright (c) 2004. Brian Ingerson. All rights reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html

=cut