Name

File::DataClass::Functions - Common utility functions

Synopsis

use File::DataClass::Functions qw( list of functions to import );

Description

Common functions used in this distribution

Subroutines/Methods

ensure_class_loaded

ensure_class_loaded( $some_class, \%options );

Require the requested class, throw an error if it doesn't load

extension_map

$map   = extension_map;                     # Accessor
$value = extension_map $class, $extensions; # Mutator

An accessor / mutator for the stateful hash reference that maps filename extensions onto storage classes. Calling the accessor populates the extension map on first use. Storage subclasses call the mutator to register the extensions that they handle. If the $extensions parameter is an array reference then the storage subclass can "claim ownership" of more than one extension in a single call

first_char

$single_char = first_char $some_string;

Returns the first character of $string

is_arrayref

$bool = is_arrayref $scalar_variable

Tests to see if the scalar variable is an array reference

is_coderef

$bool = is_coderef $scalar_variable

Tests to see if the scalar variable is a code reference

is_hashref

$bool = is_hashref $scalar_variable

Tests to see if the scalar variable is a hash reference

is_member

$bool = is_member 'test_value', qw( a_value test_value b_value );

Tests to see if the first parameter is present in the list of remaining parameters

is_mswin

$bool = is_mswin;

Returns true if running on mswin32 false otherwise

is_ntfs

$bool = is_ntfs;

Returns true if running on ntfs false otherwise

is_stale

$bool = is_stale $data, $cache_mtime, $path_mtime;

Returns true if there is no data or the cache mtime is older than the path mtime. Always returns true on NTFS

map_extension2class

$array_ref_of_class_name = map_extension2class $extension;

Maps a filename extensions to a list of storage classes

merge_attributes

$dest = merge_attributes $dest, $src, $attr_list_ref;

Merges attribute hashes. The $dest hash is updated and returned. The $dest hash values take precedence over the $src hash values. The $src hash may be an object in which case its accessor methods are called

merge_file_data

merge_file_data $existing, $new;

Uses Hash::Merge to merge data from the new hash ref in with the existing

merge_for_update

$bool = merge_for_update $dest_ref, $src, $filter;

Only merge the attributes from $src to $dest_ref if the $filter code reference evaluates to true when called with a candidate value. Return true if the destination reference was updated

qualify_storage_class

$storage_classname = qualify_storage_class $class_suffix;

Prepends the STORAGE_BASE classname to the supplied suffix

supported_extensions

@list_of_extension_names = supported_extensions;

Returns a list of supported filename extensions

thread_id

$thread_id = thread_id;

Returns the current thread id or zero if the the threads module has not been loaded

throw

throw error => 'error_key', args => [ 'error_arg' ];

Expose throw. The exception class can be changed by calling the Exception_Class class method

Configuration and Environment

None

Diagnostics

None

Dependencies

Exporter
Hash::Merge
Module::Runtime
Try::Tiny
Unexpected

Incompatibilities

There are no known incompatibilities in this module

Bugs and Limitations

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Acknowledgements

Larry Wall - For the Perl programming language

Author

Peter Flanigan, <pjfl@cpan.org>

License and Copyright

Copyright (c) 2017 Peter Flanigan. All rights reserved

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

This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE