Justin Hunter > Cantella-Store-UUID > Cantella::Store::UUID::File

Download:
Cantella-Store-UUID-0.003003.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.003003   Source  

NAME ^

Cantella::Store::UUID::File - File represented by a UUID

A NOTE ABOUT EXTENSIONS ^

To make file location deterministic, files are stored under only their UUID, along with their respective meta file which is named $UUID.meta eg (DD5EB40A-164B-11DE-9893-5FA9AE3835A0.meta). The meta files may contain any number of key/value pairs relevant to the file such as the original file name, extension, MIME type, etc. Meta files are stored in JSON format.

ATTRIBUTES ^

Cantella::Store::UUID is a subclass of Moose::Object. It inherits the new object provided by Moose. All attributes can be set using the new constructor method, or their respecitive writer method, if applicable.

uuid

uuid - reader

Required, read-only Data::GUID object, will automatically coerce.

dir

dir - reader

Required, read-only Path::Class::File object representing the directory where this file is stored. Automatically coercing.

path

path - reader
has_path - predicate
_build_path - builder
clear_path - clearer

Lazy-building, read-only Path::Class::File object representing the file being stored under this UUID.

metadata

metadata - accessor
has_metadata - predicate
_build_metadata - builder
clear_metadata - clearer
has_property - key predicate
set_property - key writer
get_property - key reader
clear_property - key clearer

Lazy_building, read-write hashref which contains the file's metadata. Setting it with the writer method will write the data to disk, modifying the hashref directly, or via the key writer, will not.

_meta_file

_meta_file - reader
_has_meta_file - predicate
_build__meta_file - builder
clear__meta_file - clearer

Lazy-building, read-only Path::Class::File object pointing at the meta file.

METHODS ^

new

arguments: \%arguments
return value: $object_instance

Constructor.

write_metadata

arguments: none
return value: none

Write the contents of metadata to the metadata file.

remove

arguments: none
return value: $bool_success

Removes the file and metadata file from the store. Returns true if both are removed successfully. An exception will be thrown if there is an error deleting the files.

exists

arguments: none
return value: $bool

Checks for existence of both the file and the metadata file. Returns true only if both exist.

mime_type

arguments: none
return value: $mime_type

Will return the mime-type for the file. If there is a value for the 'mime-type' property, that value will be used. If the key isn't present, File::MimeInfo will be used to find the mime-type of the file and store in the meta file.

If no mime-type can be determined, undef will be returned in scalr context and an empty list in list context.

extension

arguments: none
return value: $extension

Will return an appropriate extension for a file, by using it's mime-type, or original file name if mime-type is unavailable. If no known extension is known it returns an empty string.

SEE ALSO ^

Cantella::Store::UUID

AUTHOR ^

Guillermo Roditi (groditi) <groditi@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2009, 2010 by Guillermo Roditi.

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

syntax highlighting: