Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mixin::extrafields::driver::hashguts(3pm) [debian man page]

Mixin::ExtraFields::Driver::HashGuts(3pm)		User Contributed Perl Documentation		 Mixin::ExtraFields::Driver::HashGuts(3pm)

NAME
Mixin::ExtraFields::Driver::HashGuts - store extras in a hashy object's guts VERSION
version 0.008 SYNOPSIS
package Your::HashBased::Class; use Mixin::ExtraFields -fields => { driver => 'HashGuts' }; DESCRIPTION
This driver class implements an extremely simple storage mechanism: extras are stored on the object on which the mixed-in methods are called. By default, they are stored under the key returned by the "default_has_key" method, but this can be changed by providing a "hash_key" argument to the driver configuration, like so: use Mixin::ExtraFields -fields => { driver => { class => 'HashGuts', hash_key => "SomethingWicked" } }; METHODS
In addition to the methods required by Mixin::ExtraFields::Driver, the following methods are provided: hash_key my $key = $driver->hash_key; This method returns the key where the driver will store its extras. default_hash_key If no "hash_key" argument is given for the driver, this method is called during driver initialization. It will return a unique string to be used as the hash key. storage This method returns the hashref of storage used for extras. Individual objects get weak references to their id within this hashref. storage_for my $stash = $driver->storage_for($object, $id); This method returns the hashref to use to store extras for the given object and id. This hashref is stored on both the hash-based object (in its "hash_key" entry) and on the driver (in the entry for $id in its "storage" hash). All objects with the same id should end up with the same hash in their "hash_key" field. None of these references are weakened, which means two things: first, even if all objects with a given id go out of scope, future objects with that id will retain the original extras; secondly, memory used to store extras is never reclaimed. If this is a problem, use a more sophisticated driver. AUTHOR
This code was written by Ricardo SIGNES. His code in 2006 was sponsored by Listbox. COPYRIGHT AND LICENSE
Copyright (C) 2006, Ricardo SIGNES. This code is free software, and is available under the same terms as perl itself. perl v5.10.1 2010-01-19 Mixin::ExtraFields::Driver::HashGuts(3pm)

Check Out this Related Man Page

Mixin::ExtraFields::Driver(3pm) 			User Contributed Perl Documentation			   Mixin::ExtraFields::Driver(3pm)

NAME
Mixin::ExtraFields::Driver - a backend for extra field storage VERSION
version 0.008 SYNOPSIS
This is really not something you'd use on your own, it's just used by Mixin::ExtraFields, but if you insist... my $driver = Mixin::ExtraFields::Driver::Phlogiston->from_args(\%arg); $driver->set($obj, $obj_id, flammable => "very!"); DESCRIPTION
Mixin::ExtraFields::Driver is a base class for drivers used by Mixin::ExtraFields -- hence the name. A driver is expected to store and retrieve data keyed to an object and a name or key. It can store this in any way it likes, and does not need to guarantee persistence across processes. SUBCLASSING
All drivers must implement the four methods listed below. The base class has implementations of these methods which will die noisily ("confess"-ing) when called. Almost all methods are passed the same data as their first two arguments: $object, the object for which the driver is to find or alter data, and $id, that object's unique id. While this may be slighly redundant, it keeps the id-finding call in one place. from_args my $driver = Mixin::ExtraFields::Driver::Subclass->from_args(\%arg); This method must return a driver object appropriate to the given args. It is not called "new" because it need not return a new object for each call to it. Returning identical objects for identical configurations may be safe for some driver implementations, and it is expressly allowed. The arguments passed to this method are those given as the "driver" option to the "fields" import group in Mixin::ExtraFields, less the "class" option. get_all_detailed_extra my %extra = $driver->get_all_detailed_extra($object, $id); This method must return all available information about all existing extra fields for the given object. It must be returned as a list of name/value pairs. The values must be references to hashes. Each hash must have an entry for the key "value" giving the value for that name. set_extra $driver->set_extra($object, $id, $name, $value); This method must set the named extra to the given value. delete_extra $driver->delete_extra($object, $id, $name); This method must delete the named extra, causing it to cease to exist. OPTIMIZING
The methods below can all be implemented in terms of those above. If they are not provided by the subclass, basic implementations exist. These implementations may be less efficient than implementations crafted for the specifics of the storage engine behind the driver, so authors of driver subclasses should consider implementing these methods. get_all_extra my %extra = $driver->get_all_extra($object, $id); This method behaves like "get_all_detailed_extra", above, but provides the entry's value, not a detailed hashref, as the value for each entry. get_extra get_detailed_extra my $value = $driver->get_extra($object, $id, $name); my $hash = $driver->get_detailed_extra($object, $id, $name); These methods return a single value requested by name, either as the value itself or a detailed hashref describing it. get_all_extra_names my @names = $driver->get_all_extra_names($object, $id); This method returns the names of all existing extras for the given object. exists_extra if ($driver->exists_extra($object, $id, $name)) { ... } This method returns true if an entry exists for the given name and false otherwise. delete_all_extra $driver->delete_all_extra($object, $id); This method deletes all extras for the object, as per the "delete_extra" method. AUTHOR
This code was written by Ricardo SIGNES. His code in 2006 was sponsored by Listbox. COPYRIGHT AND LICENSE
Copyright (C) 2006, Ricardo SIGNES. This code is free software, and is available under the same terms as perl itself. perl v5.10.1 2010-01-19 Mixin::ExtraFields::Driver(3pm)
Man Page