-
-
16 Nov 2010 12:50:36 UTC
- Distribution: LocalOverride
- Module version: 1
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues
- Testers (680 / 7 / 0)
- Kwalitee
Bus factor: 0- 96.83% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (11.3KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
LocalOverride - Transparently override subs with those in local module versions
VERSION
version 1.000
SYNOPSIS
use LocalOverride; # Load Foo, followed by Local::Foo use Foo;Or
use LocalOverride ( base_namespace => 'MyApp', local_prefix => 'Custom' ); # Just load Moose, since it's not in MyApp::* use Moose; # Load MyApp::Base, followed by MyApp::Custom::Base use MyApp::BaseDESCRIPTION
When this module is loaded and you
useorrequireanother module, it will automatically check for whether any local modules are present which override code from the module being loaded. By default, these override modules are placed in the file system at a location corresponding toLocal::[original module name], however their code should be within the same package as the original module:In /path/to/libs/Foo.pm: package Foo; sub bar { ... } sub baz { ... } In /path/to/libs/Local/Foo.pm: package Foo; # Not Local::Foo! sub bar { ... } # Replaces the original sub Foo::barThis is, obviously, a very extreme approach and one which should be used only after due consideration, as it can create bugs which are very difficult to debug if not used carefully.
If warnings are enabled, this will generate warnings about any redefined subroutines. You will typically want to include
no warnings 'redefine';in your override modules to prevent this.
CONFIGURATION
The following configuration settings can be used to enable/disable loading of local override modules or customize where they are located. They can be set either by including them as parameters to
use LocalOverrideor by setting$LocalOverride::[option].Note that, because
useis processed at compile-time, any changes made using the latter method must be made within aBEGINblock if they are intended to affect modules that youuse. This is not necessary for modules yourequire, asrequireis processed within the normal flow of the program.base_namespace
Default: ''
Local overrides will only be loaded for modules which fall within the base namespace. For example, if
$base_namespaceis set to 'Foo', then an override module will be loaded forFoo::Bar, but not forBarorCGI.If
$base_namespaceis set, overrides will be searched for within that namespace, such asFoo::Local::Bar(notLocal::Foo::Bar) in the previous paragraph's example case.The default setting, an empty string, will attempt to load local overrides for all modules. Setting
$base_namespaceis recommended in order to avoid this.core_only
Default: 0
If this is set to a true value, then local override processing will be disabled.
This module can also be disabled with
no LocalOverrideif you prefer to unload it more completely.local_prefix
Default: 'Local'
The local prefix defines the namespace (within
$base_namespace) used for local override definitions.AUTHOR
Dave Sherohman <dsheroh@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Lund University Library Head Office.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install LocalOverride, copy and paste the appropriate command in to your terminal.
cpanm LocalOverrideperl -MCPAN -e shell install LocalOverrideFor more information on module installation, please visit the detailed CPAN module installation guide.