Commit 6c470839 authored by Nigel Kukard's avatar Nigel Kukard

Added support to get passed the parent DataObj

parent 7ecb5531
......@@ -69,9 +69,14 @@ The C<new> method is used to instantiate the object, in this case a root relatio
# Class instantiation
sub new
{
my ($class,$childClass) = @_;
my ($class,$parent,$childClass) = @_;
# Check if we firstly have a parent object
if (!defined($parent)) {
die "Parent object is required for DataObj::Relation";
}
# If there is no child class defined, we need to abort
if (!defined($childClass)) {
die "Child class is required for DataObj::Relation";
......@@ -79,6 +84,7 @@ sub new
# These are our internal properties
my $self = {
'_parent' => $parent,
'_child' => undef,
'_child_class_name' => $childClass
};
......@@ -86,6 +92,9 @@ sub new
# Build our class
bless($self, $class);
# Initialize the object
$self->init($parent,$childClass);
return $self;
}
......@@ -153,6 +162,28 @@ sub _relationChildClass
# Return relation parent object
sub _relationParentObject
{
my $self = shift;
return $self->{'_parent'};
}
# We need a specialized destroyer here to dispose of the reference to the parent object as it references us too
sub DESTROY
{
my $self = shift;
delete($self->{'_parent'});
}
1;
__END__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment