This package provides a variety of abstract interfaces for constructors and accessor methods, which form a common foundation for meta-methods provided by the Hash, Scalar, Flyweight, Static, PackageVar, and ClassVar implementations.

Generally speaking, the Generic meta-methods define calling interfaces and behaviors which are bound to differently scoped data by each of those implementations.

(Note that those implementation classes are not subclasses of Generic; instead they import various interfaces and code fragments from the meta-method types defined here, by specifying '-import' values which are processed by Class::MakeMethods's _metamethod_definition mechanism.)

There are several types of hash-based object constructors to choose from.

Each of these methods creates and returns a reference to a new blessed instance. They differ in how their (optional) arguments are interpreted to set initial values, and in how they operate when called as class or instance methods.

If called as a class method, creates, blesses, and returns a new instance. If called as an object method, operates on and returns the existing instance.

Accepts name-value pair arguments, or a reference to hash of such pairs, and calls the named method for each with the supplied value as a single argument. (See the Universal method_init behavior for more discussion of this pattern.)

(Note that while you can use the scalar methods to store references to various data structures, there are other meta-methods defined below that may be more useful for managing references to arrays, hashes, and objects.)

If the join parameter is defined, each time the get_concat behavior is invoked, it will glue its argument onto any existing value with the join string as the separator. The join field is applied between values, not prior to the first or after the last. Defaults to undefined

Creates string accessor methods, like string above, but also maintains a static hash index in which each object is stored under the value of the field when the slot is set.

This is a unique index, so only one object can have a given key. If an object has a slot set to a value which another object is already set to the object currently set to that value has that slot set to undef and the new object will be put into the hash under that value.

Objects with undefined values are not stored in the index.

Note that to free items from memory, you must clear these values!

Methods:

The method find_x is defined which if called with any arguments returns a list of the objects stored under those values in the hash. Called with no arguments, it returns a reference to the hash.

Profiles:

find_or_new

'string_index -find_or_new' => [ qw / foo bar baz / ]

Just like string_index except the find_x method is defined to call the new method to create an object if there is no object already stored under any of the keys you give as arguments.

This meta-method extends the scalar meta-method, and supports the same interfaces and parameters. However, it generally treats values as true-or-false flags, and can not be used to store strings, numbers, or references.

Returns all the values for all the given keys, in order. If no keys are given, returns all the values (in an unspecified key order).

The result is returned as an arrayref in scalar context. This arrayref is not part of the data structure; messing with it will not affect the contents directly (even if a single key was provided as argument.)

If any argument is provided which is an arrayref, then the members of that array are used as keys. Thus, the trivial empty-key case may be utilized with an argument of [].

Takes a key, and some values. Pushes the values onto the list denoted by the key. If the first argument is an arrayref, then each element of that arrayref is treated as a key and the elements pushed onto each appropriate list.

Takes a key, and a list of indices. Removes each corresponding item from the named list. The indices are effectively looked up at the point of call -- thus removing indices 3, 1 from list (a, b, c, d) will remove (d) and (b).

The filter function used (as a coderef). Is passed two arguments, the value compared against, and the value in the list that is potential for grepping out. If returns true, the value is removed. Default is sub { $_[0] == $_[1] }.

In addition to creating a method to get and set the object reference, the meta-method can also define forwarded methods that automatically pass calls onto the object stored in that slot; see the description of the 'delegate' parameter below.

The methods to forward to the object. Can contain a method name, a string of space-spearated method names, or an array of method names. This type of method will croak if it is called when the target object is not defined.

The methods to forward to the object, if it is present. Can contain a method name, a string of space-spearated method names, or an array of method names. This type of method will return nothing if it is called when the target object is not defined.

Operates like Generic:array, but prior to adding any item to the array, it first checks to see if it is an instance of the designated class, and if not passes it as an argument to that class's new method and stores the result instead.

Forwarded methods return a list of the results returned by maping the method over each object in the array.

If called with an argument, either a CODE reference or some other scalar, it installs that code in the slot. Otherwise, if the current value runs the code stored in the slot with whatever arguments (including none) were passed in.