Bric::Dist::Resource

NAME

Bric::Dist::Resource - Interface to distribution files and directories.

VERSION

$LastChangedRevision$

DATE

$LastChangedDate$

SYNOPSIS

use Bric::Dist::Resource;

# Constructors.
# Create a new resource.
my $res = Bric::Dist::Resource->new;
# Look up an existing resource.
$res = Bric::Dist::Resource->lookup({ id => 1 });
# Get a list of resources.
my @res = Bric::Dist::Resource->list({ path => '/tech/feature%' });

# Class methods.
# Get a list of resource IDs.
my @res_ids = Bric::Dist::Resource->list_ids({ path => '/tech/feature%' });
# Get an introspection hashref.
my $int = Bric::Dist::Resource->my_meths;

# Instance methods.
my $id = $res->get_id;
my $path = $res->get_path;
$res = $res->set_path($path);
my $uri = $res->get_uri;
$res = $res->set_uri($uri);
my $tmp_path = $res->get_tmp_path;
$res = $res->set_tmp_path($tmp_path);
my $size = $res->get_size;
$res = $res->set_size($size);
my $mod_time = $res->get_mod_time;
$res = $res->set_mod_time($mod_time)
my $media_type = $res->get_media_type;
$res = $res->set_media_type($media_type)
print "It's a directory!\n" if $res->is_dir;

# Reload size and mod_time, from the resource on the file system.
$res = $res->stat_me;

# Story relationships.
my @story_ids = $res->get_story_ids;
$res = $res->add_story_ids(@story_ids);
$res = $res->del_story_ids(@story_ids);

# Media relationships.
my @media_ids = $res->get_media_ids;
$res = $res->add_media_ids(@media_ids);
$res = $res->del_media_ids(@media_ids);

# File relationships.
if ($res->is_dir) {
    my @file_ids = $res->get_file_ids;
    $res = $res->add_file_ids(@file_ids);
    $res = $res->del_file_ids(@file_ids);
}

# Save it!
$res = $res->save;

DESCRIPTION

This class manages distribution resources. A resource is a file or directory. Directory resources can be associated with file resources (in order to keep a list of the contents of a directory), but not vice versa. Resources may also track associations with assets, such that they can have story and/or media associations. Other properties of resources are filesystem path, file size, MEDIA type, and last modified date.

INTERFACE

Constructors

Destructors

Public Class Methods

Public Instance Methods

PRIVATE

Private Class Methods

NONE.

Private Instance Methods

NONE.

Private Functions

NOTES

NONE.

AUTHOR

David Wheeler

SEE ALSO

Bric, Bric::Util::Job