Class::ReluctantORM::Utilities - Utility subroutines
use Class::ReluctantORM::Utilities qw(:all); install_method('Some::Class', 'method_name', $coderef); conditional_load('Class::Name'); # Look for and load all modules under the location of Super::Class # (handy for loading driver subclasses) BEGIN { @classes = conditional_load_subdir('Super::Class'); }
An uncohesive set of utility methods. Several are for test manipulation; some are for class loading or interface manipulation.
No subroutines are exported by default, but all are available by request.
Installs a new method in a class. The class need not exist.
$clobber determines what to do if the named method already exists. If clobber is true, the existing method is renamed to __orig_method_name, and $coderef is installed as method_name. If clobber is false, the existing method is untouched, and the $coderef is installed as __new_method_name .
If the named method does not exist, the coderef is installed and $clobber has no effect.
Installs a method generator for as-needed method creation. An AUTOLOAD hook will check to see if any generator can make a method by the given name. Multuple generators can be installed for each class.
$class is a Class::ReluctantORM subclass.
$generator is a coderef. It will be called with two args: the class name, and the proposed method name. If the generator can generate a method body, it should do so, and return a coderef which will then be installed under that name. If no candidate can be created, it should return undef.
Loads Class::Name if it hasn't already been loaded.
Finds Super::Class on the filesystem, then looks for and loads all modules Super/Class/*.pm If $depth is present, directories are searched up to $depth deep (so $depth =2 gives Super/Class/*.pm Super/Class/*/*.pm Super/Class/*/*/*.pm)
It's best to call this from within a BEGIN block, if you are trying to find driver modules.
Returns a list of loaded classes.
Given the args list (which is assumed to have $self or $class already shifted off), check the args list for required, optional, and mutually exclusive options.
If a arrayref, checks to make sure it is even-numbered. If a hashref, used as-is.
List of args that are required.
List of args that are permitted but optional.
Listref of listrefs. Each inner listref is a set of parameters that is mutually exclusive, that is, AT MOST one the params may appear.
Like mutex, but EXACTLY ONE of the params of each set must appear.
When throwing an exception, the number of frames to jump back. Default is 2.
Converts a string in camel case (LikeThis) to one in underscore case (like_this).
Returns the plural form of a word.
If $input is defined, $outout = $input.
If $input is undef, $output = $output_if_undef.
Named after the same function in Visual Basic, where all good ideas originate.
Returns true if the arrays referred to by the arrayrefs $ary1 and $ary2 are identical in a shallow sense, using 'eq'.
Returns information about the the last call stack frame outside of Class::ReluctantORM.
In scalar context, returns only the last call frame. In list context, returns the last stack frame and up.
$info will contain keys 'file', 'package', 'line', and 'frames'. Frames indicates the value passed to caller() to obtain the information, which is the number of frames to unwind.
Calculates the size, in bytes, of the values of the given hashref. This is used by the RowSize and QuerySize Monitors.
File::Slurp::read_file workalike, but far crappier.
File::Slurp::write_file workalike, but far crappier.
Version-blind JSON encoder.
Version-blind JSON decoder.
To install Class::ReluctantORM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::ReluctantORM
CPAN shell
perl -MCPAN -e shell install Class::ReluctantORM
For more information on module installation, please visit the detailed CPAN module installation guide.