| 1 | # $File: //member/autrijus/DBIx-ReportBuilder/lib/DBIx/ReportBuilder/Clause.pm $ $Author: autrijus $ | ||
| 2 | # $Revision: #4 $ $Change: 8713 $ $DateTime: 2003/11/06 15:12:20 $ | ||
| 3 | |||
| 4 | package DBIx::ReportBuilder::Clause; | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use base 'DBIx::ReportBuilder::Part'; | ||
| 8 | use constant ElementClass => __PACKAGE__; | ||
| 9 | |||
| 10 | sub Insert { | ||
| 11 | my ($self, %args) = @_; | ||
| 12 | my $tag = $args{tag} or die("Can't insert a tagless clause"); | ||
| 13 | return $self->SUPER::Insert(%args) | ||
| 14 | if $self->parent and $self->parent->tag eq "${tag}s"; | ||
| 15 | |||
| 16 | # We don't have any siblings... paste into the collection object | ||
| 17 | my $parent = $args{Object}->PartObj->first_child("${tag}s"); | ||
| 18 | if (!$parent) { | ||
| 19 | $parent = $self->new("${tag}s"); | ||
| 20 | $parent->paste(last_child => $args{Object->PartObj}); | ||
| 21 | } | ||
| 22 | my $part = $self->new($tag, %args); | ||
| 23 | $part->paste(last_child => $parent); | ||
| 24 | $part->Change(%args); | ||
| 25 | return $part; | ||
| 26 | } | ||
| 27 | |||
| 28 | sub Remove { | ||
| 29 | my $self = shift; | ||
| 30 | $self->delete; | ||
| 31 | return -1; | ||
| 32 | } | ||
| 33 | |||
| 34 | 1; |