| 1 | |||
| 2 | package DBIx::Romani::Query::Delete; | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | |||
| 6 | sub new | ||
| 7 | { | ||
| 8 | my $class = shift; | ||
| 9 | my $args = shift; | ||
| 10 | |||
| 11 | my $from; | ||
| 12 | |||
| 13 | if ( ref($args) eq 'HASH' ) | ||
| 14 | { | ||
| 15 | $from = $args->{from}; | ||
| 16 | } | ||
| 17 | else | ||
| 18 | { | ||
| 19 | $from = $args; | ||
| 20 | } | ||
| 21 | |||
| 22 | my $self = { | ||
| 23 | from => $from, | ||
| 24 | where => undef | ||
| 25 | }; | ||
| 26 | |||
| 27 | bless $self, $class; | ||
| 28 | return $self; | ||
| 29 | } | ||
| 30 | |||
| 31 | sub get_from { return shift->{from}; } | ||
| 32 | sub get_where { return shift->{where}; } | ||
| 33 | |||
| 34 | sub set_where | ||
| 35 | { | ||
| 36 | my ($self, $where) = @_; | ||
| 37 | $self->{where} = $where; | ||
| 38 | } | ||
| 39 | |||
| 40 | sub visit | ||
| 41 | { | ||
| 42 | my ($self, $visitor) = @_; | ||
| 43 | $visitor->visit_delete( $self ); | ||
| 44 | } | ||
| 45 | |||
| 46 | sub clone | ||
| 47 | { | ||
| 48 | my $self = shift; | ||
| 49 | |||
| 50 | my $query = DBIx::Romani::Query::Delete->new({ from => $self->get_from() }); | ||
| 51 | |||
| 52 | if ( $self->get_where() ) | ||
| 53 | { | ||
| 54 | $query->set_where( $self->get_where()->clone() ); | ||
| 55 | } | ||
| 56 | |||
| 57 | return $query; | ||
| 58 | } | ||
| 59 | |||
| 60 | 1; | ||
| 61 |