Data-Inherited
view release on metacpan or search on metacpan
lib/Data/Inherited.pm view on Meta::CPAN
invoked. The resulting hash is the combined set of results from all the
methods, overlaid in top-to-bottom order (hierarchy-wise).
C<every_hash()> returns a hash in list context and a hash reference in scalar
context.
The cache and the optional cache override argument work like with
C<every_list()>.
Example:
package Person;
use base 'Data::Inherited';
sub new {
my $class = shift;
my $self = bless {}, $class;
my %args = @_;
%args = ($self->every_hash('DEFAULTS'), %args);
$self->$_($args{$_}) for keys %args;
$self;
};
sub DEFAULTS {
first_name => 'John',
last_name => 'Smith',
};
package Employee;
use base 'Person';
sub DEFAULTS {
salary => 10_000,
}
package LocatedEmployee;
use base 'Employee';
# Note: no default for address, but different salary
sub DEFAULTS {
salary => 20_000,
first_name => 'Johan',
}
package main;
my $p = LocatedEmployee->new;
# salary: 20000
# first_name: Johan
# last_name: Smith
=head2 flush_every_cache_by_key(String $key)
Deletes the cache entry for the given key.
=head1 INSTALLATION
See perlmodinstall for information and options on installing Perl modules.
=head1 BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests through the web interface at
L<http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Inherited>.
=head1 AVAILABILITY
The latest version of this module is available from the Comprehensive Perl
Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN
site near you, or see
L<http://search.cpan.org/dist/Data-Inherited/>.
The development version lives at
L<http://github.com/hanekomu/Data-Inherited/>.
Instead of sending patches, please fork this project using the standard git
and github infrastructure.
=head1 AUTHOR
Marcel Gruenauer <marcel@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2004 by Marcel Gruenauer.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 1.921 second using v1.01-cache-2.11-cpan-39bf76dae61 )