Name : perl-Class-Data-ConfigHash
| |
Version : 0.00002
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 10.43
| Date : 2024-08-05 19:58:04
|
Group : Development/Libraries/Perl
| Source RPM : perl-Class-Data-ConfigHash-0.00002-10.43.src.rpm
|
Size : 0.01 MB
| |
Packager : (none)
| |
Summary : Add Catalyst-style config to your class
|
Description :
I often times find myself wanting a per-class config that can be used to provide sane class-level defaults, but with the ability to easily customize the values at run time.
package MyClass; __PACKAGE__->config({ foo => 1, bar => 2 });
my %config = read_config_from_file() ; # say, %config = ( foo => 3 ) MyClass->config(\\%config);
MyClass->config->{foo}; # yields 3 MyClass->config->{bar}; # yields 2
The idea is that you can hardcode the defaults in your class, but you can also easily override them by merging the original hash with a newly given hash. This feature is handled beautifully in Catalyst.
So there, this module is basically that feature from Catalyst ripped out to a separate module so it can be used elsewhere.
To use, simply subclass it in your module:
package MyClass; use base qw(Class::Data::ConfigHash);
Done! Now you can use ->config in MyClass.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-C/openSUSE_Tumbleweed/noarch |