
Class::IntrospectionMethods::Parent - Handles parent relationship for Class::IntrospectionMethods

No synopsis. Directly used by Class::IntrospectionMethods

This class handles parent relationship for Class::IntrospectionMethods.
In other word, for any child object managed by Class::IntrospectionMethods, it will :
weaken function)By default, the name of the installed function and arribute is cim_parent but this can be changed by calling set_parent_method_name.

This function changes the name of the function and attribute names installed by graft_parent_method. (cim_parent by default)
Creates the ParentInfo object, install the cim_parent function in child's class, store the ParentInfo in child object, finally store slot and index in ParentInfo object.

A ParentInfo object is created each time the graft_parent_method function is called.
When, needed, this object is retrieved by calling:
$child->cim_parent
The the following methods may be applied to retrive the informations stored durung graft_parent_method call:
Returns the index value of the element containing the child object. Returns undex if the Class::IntrospectionMethods slot is not hash or array based.
Identical to index_value. This method may be preferred for hash based slots. (This is just syntactical sugar).
Returns the name of the IntrospectionMethods slot containing the child object.
Returns the parent object containing child.

package X ;
use Class::IntrospectionMethods
qw/make_methods set_parent_method_name/;
set_parent_method_name('metadad') ;
make_methods
(
'parent',
hash =>
[
a => {
tie_hash => ['MyHash', dummy => 'booh'],
class_storage => ['MyObj', 'a' => 'foo']
},
],
new => 'new'
);
package main;
my $o = new X;
my $obj = $o->a('foo') ;
my $info = $obj->metadad ;
my $p= $info->parent; # $p is $o
print $info->slot_name; # -> 'a'
print $info->index_value; # -> 'foo'
# check parent method on object behind tied hash
my $tied_hash_obj = $o->tied_hash_a ;
my $p2 = $tied_hash_obj->metadad->parent; # $p2 is $o

Copyright (c) 2004 Dominique Dumont. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

L<Class::IntrospectionMethods>