NAME
Object::Accessor::Inheritable -- Enable data inheritance between objects
SYNOPSIS
$Class = 'Object::Accessor::Inheritable';
my $parent = $Class->new( qw[parent_method shared_method] );
my $child = $Class->new( qw[child_method shared_method] );
$child->parent( $parent ); # define the relationship
$parent->parent_method( $$ ); # set the value in the parent
$child->child_method( $$ ); # set the value in the child;
print $child->parent_method; # print it from the child
print $parent->child_method; # error; no such method for parent
$parent->shared_method( 'p' ); # set the value in the parent
$child->shared_method( 'c' ); # set another value in the child
print $parent->shared_method; # prints 'p'
print $child->shared_method; # prints 'c'
DESCRIPTION
Object::Accessor::Inheritable
lets you inherit data between Object::Accessor::Inheritable
objects by defining a relationship between these objects. This works analogous to perl
s own @ISA
resolving, but rather than on classes, it works on objects.
METHODS
$obj = Object::Accessor::Inheritable->new( ... )
This creates a new Object::Accessor::Inheritable
object. This is just a wrapper around Object::Accessor
, so all arguments are passed straight on to it's new
method. Please consult the Object::Accessor
manpage for details on the arguments.
In addition, it adds the parent
method to your object, so you can define relationships between this object, and other objects of the Object::Accessor::Inheritable
class.
By default, data retrievel is down bottom up
, meaning we prefer child data over parent data. The alternative is to retrieve data top down
, where parent data is prefered over child data.
To allow top down
retrieval, create your object as follows instead:
$topdown = Object::Accessor::Inheritable::TopDown->new( ... )
You can also be explicit in your bottom up
preference by declaring your object as follows:
$bottomup = Object::Accessor::Inheritable::BottomUp->new( ... )
$parent = $obj->parent | $obj->parent( $parent )
Get or set the parent of this object. It should be another Object::Accessor::Inheritable
, or an object that supports the same interface, providing it's own parent
method.
SEE ALSO
Object::Accessor
AUTHOR
Jos Boumans kane@cpan.org
BUGS
Please report bugs to bug-object-accessor-inheritable@rt.cpan.org
COPYRIGHT
This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.