1Mixin::ExtraFields::DriUvseerr::CHoansthrGiubtust(e3d)PMeirxlinD:o:cEuxmternatFaiteilodns::Driver::HashGuts(3)
2
3
4

NAME

6       Mixin::ExtraFields::Driver::HashGuts - store extras in a hashy object's
7       guts
8

VERSION

10       version 0.140002
11

SYNOPSIS

13         package Your::HashBased::Class;
14
15         use Mixin::ExtraFields -fields => { driver => 'HashGuts' };
16

DESCRIPTION

18       This driver class implements an extremely simple storage mechanism:
19       extras are stored on the object on which the mixed-in methods are
20       called.  By default, they are stored under the key returned by the
21       "default_has_key" method, but this can be changed by providing a
22       "hash_key" argument to the driver configuration, like so:
23
24         use Mixin::ExtraFields -fields => {
25           driver => { class => 'HashGuts', hash_key => "\0Something\0Wicked\0" }
26         };
27

METHODS

29       In addition to the methods required by Mixin::ExtraFields::Driver, the
30       following methods are provided:
31
32   hash_key
33         my $key = $driver->hash_key;
34
35       This method returns the key where the driver will store its extras.
36
37   default_hash_key
38       If no "hash_key" argument is given for the driver, this method is
39       called during driver initialization.  It will return a unique string to
40       be used as the hash key.
41
42   storage
43       This method returns the hashref of storage used for extras.  Individual
44       objects get weak references to their id within this hashref.
45
46   storage_for
47         my $stash = $driver->storage_for($object, $id);
48
49       This method returns the hashref to use to store extras for the given
50       object and id.  This hashref is stored on both the hash-based object
51       (in its "hash_key" entry) and on the driver (in the entry for $id in
52       its "storage" hash).
53
54       All objects with the same id should end up with the same hash in their
55       "hash_key" field.  None of these references are weakened, which means
56       two things:  first, even if all objects with a given id go out of
57       scope, future objects with that id will retain the original extras;
58       secondly, memory used to store extras is never reclaimed.  If this is a
59       problem, use a more sophisticated driver.
60

AUTHOR

62       Ricardo Signes <rjbs@cpan.org>
63
65       This software is copyright (c) 2013 by Ricardo Signes.
66
67       This is free software; you can redistribute it and/or modify it under
68       the same terms as the Perl 5 programming language system itself.
69
70
71
72perl v5.28.1                      2013-1M0i-x0i3n::ExtraFields::Driver::HashGuts(3)
Impressum